Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I have a folder in which there are hundreds of files that have been created with %20 in them. Is there any way of doing a bulk transformation on those names to replace them with spaces or underscores?
Really strange. You can try with exec - or better eval. Or you can do a simple string replacement like this
Code:
mv $file "${file//\%20/ }"
Anyway, I strongly suggest to replace with an underscore instead of a blank space. This will avoid some other problems when managing the renamed files.
I think you used the wrong character in the line reading
Code:
fname=`echo $f | sed s/%20/\ /g`
The single quote used here must be from the key next to the "1" at the top right hand corner of the US keyboard layout - NOT the single quote found underneath the double quote. Another way to express the same command, without the potential for this error, is:-
Code:
fname=$(echo $f | sed s/%20/\ /g)
Last edited by blacky_5251; 04-17-2008 at 06:08 AM.
Just to reinforce colucix' comment, do replace with underscores, not spaces, as many Unix cmds/tools do not behave well with spaces in filenames (default design is that args to cmds are space separated ...)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.