6V8 - Production of my Mind

Home page > For your Computer > Mass renaming with linux shell > Mass renaming with linux shell > Post a message

Post a message Replying to: Mass renaming with linux shell

23 September 2003, by Mortimer
When you do mv *.aaa *.bbb, it’s not obvious to a newbie that it won’t work.
The solution is a bit more tricky and needs piping (; ) and sed.
Renaming
So, if you wanted to rename all the .php3 to .php, this would be the command:
ls -d *.php3 ; sed ’s/\(.*\).php3$/mv "&" "\1.php"/’ ; sh
so what does this do?
ls -d *.php3 outputs a list of all the php3 files in the directory. This list is piped to the second command,
sed ’s/\(.*\).php3$/mv "&" "\1.php"/’ is not as obvious for newbies. sed (...)
 
©
Pierre Andrews
York, uk
| Site Map | Site created with SPIP 1.9.2c [10268] | RSS | template by IZO, Mortimer. | clicky stats
of is Tina is while
of is Tina is while
of is Tina is while
of is Tina is while
of is Tina is while