Main /

Remove Pattern From File Name

edit SideBar

Remove Pattern From File Name

Remove a pattern from a bunch of filenames. For example say you have a bunch of files named VacationPhotos1.jpg, VacationPhotos2.jpg, VacationPhotos3.jpg, etc and you wish to remove the Photos part. The following bash script will do the trick:

for file in *; do mv $file `echo $file | sed s/Photos//`; done

If the filenames contain spaces remove those first (see RemoveSpaces).

Recent Changes (All) | Edit SideBar Page last modified on December 03, 2006, at 04:41 PM Edit Page | Page History
Powered by PmWiki