Little batch script to rename directories
Posted on 2004-11-14
I'd like to rename some special folders on my harddisk. All the folders are looking this way:
[PPP] - ( this text is variable ) - [PPP]
Now I want to exchange all the [PPP] with [TTT] for example, the rest should be left untouched. With my very basics in batch programming I made the following script:
for FILE in "`find / -type d -name "?PPP]*" -print`"
OLDNAME=`echo -n "$FILE"`
NEWNAME=`echo -n "$FILE" | sed "s/PPP/TTT/g"`
mv $OLDNAME $NEWNAME
Unfortunately, this seems not to work. When I do an "echo $OLDNAME" then I get a string with all the oldnamed directories without \n (newline).
Thanks for every helpful input in this :-)