Rename files by regexp in command line
There is a command called (in an excess of originality) rename
, that allows you to rename files using regular expressions.
In this case, you probably want to do:
rename 's/\*//' files...
Which will remove the first *
character found in each filename.
You can use rename -n
to list the renames that will be performed without actually doing them if you're worried about the regex not being correct.
Ubuntu comes with the rename
command which can rename files by regular expressions.
If all your files are located in the same folder, you can simply do the following:
rename s/\\*$// *
(\\*
is an escaped *
, $
is the end of the file name. A match will be replaced with nothing.)
If all your files are in a directory structure, you can use find:
find / -exec rename s/\\*$// {} \;
Which executes rename /\\*$//
on every file and directory on you system. Feel free to change the /
to the folder in which the directory structure is located.