Re: [FishMonger] rename a batch of files in a folderr - how to do this in commandline
[In reply to]

Can't Post

hello dear fishmonger,

as most standard shells provide a way to do simple text substitution within shell variables. i had a quick look at the linux documentation project - see here http://tldp.org/LDP/abs/html/parameter-substitution.html explains as follows:

${var/Pattern/Replacement}

First match of Pattern, within var replaced with Replacement.

So use this script to loop through all the appropriate files and rename each of them:

well - i have a little thing to the code: i have added a -i option so you have the chance to confirm each renaming operation. As always, you should make a backup of all your files before doing any large amount of renaming or deleting.

Re: [dilbert] rename a batch of files in a folderr - how to do this in commandline
[In reply to]

Can't Post

That's shell code and this is a perl forum. If you want a shell solution, then you might want to post your question in a shell forum. If you want a perl solution, then write your perl script and if you need help troubleshooting it, post your code and update your question.

Perl has the File::Copy module you can (and probably should) use but you can also make system calls to the systems mv command.

Re: [dilbert] rename a batch of files in a folderr - how to do this in commandline
[In reply to]

Can't Post

Note that there is also a rename Perl internal command which may do just what you need.

It has a few gotchas when trying to move files around, but if you're just renaming files, it should probably be OK, provided you check that there is no existing file having the new name (existing files having the target name would be clobbered).