Copy and rename multiple files in Linux
Copy and rename multiple files from command line based on a pattern.
for i in `ls *`; do cp $i `echo $i | sed "s/search/replace/g"`; done
Option g tells sed to search and replace the entire line not to stop after the first occurrence of the search pattern.
If you want only to rename the files use the rename command (the example below search for "searchString" and replace it with "replaceString" in all the file names of the current folder with .ogg extension):
rename 's/searchString/replaceString/' *.ogg
If you want to replace a string which is found multiple times in one file name use the /g modifier:
rename 's/searchString/replaceString/g' *.ogg
Latest news
- - S5 Slide Show System: PowerPoint on Linux
- - µTorrent for Linux
- - Linux audio tagger
- - Gnome 3 release date - interview with Stormy Peters
- - Ubuntu Maverick Meerkat Beta Released
- - Ubuntu Maverick Meerkat frozen
- - Tab Candy for Firefox
- - Ubuntu font launched for beta testing
- - Interview with Richard Stallman
- - Linux Mint 9 KDE released
- - Gnome 3 release date delayed to march 2011