You are not logged in.
Pages: 1
I have a command that I'm trying to get to work. It deletes spaces, hyphens, plusses and underscores from filenames.
Code: rename "s/[-_+ ]//g" *
I've tried using this command by inserting the %f and n% command parameters in different places, but it doesn't work. When I run the command without the parameters then it will rename all files in a folder, and not just the selected files. How can I get it to rename only selected files.
Offline
You need to create a loop so that all of the selected files in %N get processed individually. Something like this works:
for file in %N; do mv "$file" `echo $file | sed -e 's/[_-+ ]//g'`; done
Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline
Thank you! I just tested it and it works, but presents a new problem. It deletes the period that separates the file name from the file extension. So it will change 34faw-aajiew_areaf opoa.jpg to 34fawaajiewareafopoajpg
Offline
Sorry, my QA failed me today. Try this one instead:
for file in %N; do mv "$file" `echo $file | sed -e 's/[ _+-]//g'`; done
Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline
Thanks, that works perfect!
Offline
Pages: 1
[ Generated in 0.007 seconds, 10 queries executed - Memory usage: 529.18 KiB (Peak: 530.46 KiB) ]