LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Rename multiple files in folders??? (https://www.linuxquestions.org/questions/linux-software-2/rename-multiple-files-in-folders-480473/)

derek11 09-06-2006 01:15 AM

thanks RedNovember, i'm afraid i did not installed KDE/GNOME on the server, and server is located in remote location.

adds2one 10-04-2006 12:56 AM

Quote:

Originally Posted by rhoekstra
You could try it like this:

Code:

for i in `find . -name .folder.jpg`;do mv $i ${i/.folder.jpg/folder.jpg};done

This works great when the directory names are one word but doesn't work for most of my directories which are album titles such as:

To Bring You My Love which Linux sees as:

To\ Bring\ You\ My\ Love/

Your script seems to try to go into folder To\ then Bring\ then You\ etc....

Here is an example of the message I get:

mv: cannot stat `./Murray': No such file or directory
mv: cannot stat `Street/.folder.jpg': No such file or directory
mv: cannot stat `./Daydream': No such file or directory
mv: cannot stat `Nation/.folder.jpg': No such file or directory

Thanks so much for your help.

doc.nice 10-04-2006 04:08 AM

Code:

for i in `find . -name .folder.jpg`;do mv "$i" "${i/.folder.jpg/folder.jpg}";done
some litte dashes should help ;)

rhoekstra 10-04-2006 02:19 PM

Quote:

Originally Posted by derek11
hi rhoekstra, thank you, it works nicely on files in deep directories, but would not replace illegal characters in directory names thou.

It should rename directories as well, but this line:
Code:

$newfile=~ s/[,& '\(\)]/_/g; #Search for ',', '&', ' ', "'", '(', ')' in filenames and replace them with underscores.
takes care of identifying which characters to change with underscores...
between the '[' and ']' add additional 'illegal' characters in order to get them replaced with underscores.

A bit more advanced is to determine if the name consists of 'any' character that is not between a-z,A-Z,0-9,_,-, etc... That could be done instead of the above line perhaps... I'm figuring out how to do so.. in this case you can tell what characters ARE valid, rendering all remaining characters invalid without naming them specifically...

adds2one 10-05-2006 12:22 AM

Quote:

Originally Posted by doc.nice
Code:

for i in `find . -name .folder.jpg`;do mv "$i" "${i/.folder.jpg/folder.jpg}";done
some litte dashes should help ;)

thanks for the suggestion but this results in the exact same problem.


All times are GMT -5. The time now is 03:34 AM.