Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8141601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:33:53+00:00 2026-06-06T12:33:53+00:00

Hey guys I’m getting an error right around my second nested else, I think

  • 0

Hey guys I’m getting an error right around my second nested else, I think it has something to do with moving the file to a folder with whitespace in its name, but I’m not sure, so I tried adding in another nested if that would allow me to rename, it also is throwing an error though about formatting?

I think the real issue is that I’m nesting ifs wrong?

Error

/bin/y2m: line 16: syntax error near unexpected token `then'
/bin/y2m: line 16: `        if[ -z "$newname" ]; then'

Code

#!/bin/bash

address=$1
newname=$2
regex='v=(.*)'
if [[ $address =~ $regex ]]; then
    video_id=${BASH_REMATCH[1]}
    video_id=$(echo $video_id | cut -d'&' -f1)

    if[ -z "$newname" ]; then
        video_title="$newname"
    else
        video_title="$(youtube-dl --get-title $address)"
    fi

    youtube-dl -o "$video_title".flv $address
    ffmpeg -i "$video_title".flv -acodec libmp3lame -ac 2 -ab 256k -vn -y "$video_title".mp3

        if [ -d "/media/SDHC CARD/Music/y2m" ]; then
            mv "$video_title".mp3 "/media/SDHC CARD/Music/y2m"
            echo "Moving to Phone Card"
        else
            mv "$video_title".mp3 ~/Music
            echo "Moving to Music Folder"
        fi

    rm "$video_title".flv
else
    echo "Sorry but you seemed to broken the interwebs."
fi
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T12:33:54+00:00Added an answer on June 6, 2026 at 12:33 pm

    I forgot to space my if[ it should be if [

    I revised it to this

        #!/bin/bash
        # Youtube to MP3 Bash Script
    
        # CPR : Jd Daniel :: Ehime-ken
        # REQ : sudo apt-get install youtube-dl && youtube-dl -U
        # REQ : sudo apt-get install lame
        # REQ : ffmpeg [use: http://ubuntuforums.org/showpost.php?p=4907079&postcount=1]
    
        address=$1
        newname=$2
        regex='v=(.*)'
    
        if [[ $address =~ $regex ]]; then
                video_id=${BASH_REMATCH[1]}
                video_id=$(echo $video_id | cut -d'&' -f1)
    
                if [ -n "$newname" ]; then
                        video_title="$newname"
                else
                        video_title="$(youtube-dl --get-title $address)"
                fi
    
                youtube-dl -o "$video_title".flv $address
                ffmpeg -i "$video_title".flv -acodec libmp3lame -ac 2 -ab 256k -vn -y "$video_title".mp3
    
                        if [ -d "/media/SDHC CARD/Music/y2m" ]; then
                                cp "$video_title".mp3 ~/Music && mv "$video_title".mp3 "/media/SDHC CARD/Music/y2m"
                                echo "Saving to Phone"
                        else
                                mv "$video_title".mp3 ~/Music
                                echo "Saving to Local"
                        fi
    
                rm "$video_title".flv
        else
                echo "Sorry but you seemed to broken the interwebs."
        fi
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys I'm getting three things right now that I'm trying to take care
Hey guys, I'm just starting out with GWT and am getting the following error
Hey guys I'm trying to add the string 'url( ) ' around my a
Hey guys, I'm trying to get my head around LINQ and FP, so forgive
Hey guys I'm creating a quick mysql file to create a DB with some
Hey guys I can't seem to get the syntax here right, I'm just trying
Hey guys, I got the same error when I was using kiwi to install
Hey guys - I am having trouble setting up my Django urls file correctly
hey guys, i'm getting an exception on the following inner exception: {Value cannot be
Hey guys, I'm researching something for a friend of mine who's involved in road

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.