Need to remove spaces from all file / dir names ?? Solution here!
Have you ever been faces with the problem of having a directory full of files and folders with spaces in them (take your MP3 collection for example)? Well here is an easy way to remove all those spaces and replace them with underscores. The only requirement is that you not have any files / directories with + signs in the name.
Code:
for i in `find . | tr "[:blank:]" "+" | grep "+"`; do echo "Changing Directory: " `echo $i | sed -r 's/\+/\\ /g'` " to " `echo $i | tr "+" "_"`; mv "`echo $i | sed -r 's/\+/\\ /g'`" `echo $i | tr "+" "_"`; done |
Code:
#!/bin/bash No need to re-run because of errors ... |
Ooohhh, I am saving this. I can't count the number of times a script has failed because of spaces that I could not find a way to get the shell to ignore.
Thanks guys. |
All times are GMT -5. The time now is 02:12 PM. |