Quote:
Originally Posted by aidansmoker
... how do I modify your code to deal with spaces in the folder names; the code seems to be having problems with that?
|
OK... If you're referring to the "while-do" example, I'm guessing that the "cd $DIRNAME" line is where the error lies, right? Try changing that line to read:
Single quotes should not be used because the shell substitution would break. If you're trying to get into one of these directories from the CLI, you can precede each space by a backslash ("\") or enclose the space-laden directory/file name in quotes:
Code:
cd Djam\ Karet
cd "Djam Karet"
cd 'Djam Karet'
would all work.
Single or double quotes will work in this case so long as you aren't referencing a shell variable:
Code:
cd '$GENRE/Djam Karet'
would not work (see the first code snippet's warning). Double quotes would be needed in the above example.
Boy! What I'd give for five minutes in a dark alley with a baseball bat and the bozo who thought spaces in directory and file names was a cool idea. I probably get at least one question a week at work about this. It's gotten to be second nature for me when saving files sent to me -- almost always from a Windows user but from the occasional Mac user as well -- that I automatically change all the spaces to underscores. Making that little fix once saves me
so much trouble later on. Fixing them -- or just dealing with them -- after the fact is a pain. As you're finding out. Unfortunately, I seem to recall some ripping software that seemed to want to embed spaces in sound filenames. Guess that's why I wound up sticking with cdrecord and homegrown scripts. (And guess what my scripts do with any spaces in album/song titles?
)