bash, loops and spaces in filenames
Hi.
I'm frequently using bash scripts like this: Code:
for i in `ls *`; do Code:
$ touch "a b"; touch "c d"; Code:
a b |
I hope this helps:
Code:
#!/bin/bash |
Use double quotes around the variable.
example: for song in *.mp3; do mv " ${song}" "${song// /_}"; done will replace spaces in the filenames with the underscore. You will need to place the variable in double quotes anyway in case the filename might contain characters like '()*!' which are not whitespace but have a special meaning to the shell. |
Quote:
Quote:
But I'm wondering where can I learn more about renaming in the style of ${song// /_}? |
`man bash` is a great source of information. Tip, after typing man bash[enter], type this: "/\#\#" and [enter] and you'll be right at the interesting location.
Yves. |
Quote:
|
All times are GMT -5. The time now is 09:25 AM. |