Renaming multiple files manually can be really annoying. Using the rename
command in the shell we can easily
re-write the names of multiple files. It is already pre-installed on ubuntu/debian machines.
I'll use renaming tv episodes as an example. to rename a file from "episode 1 name-of-episode.mkv" to "S01E01 name of episode.mkv" type the following command in a terminal in the directory of your files:
rename -n -e 's/episode(\d+)/S01E$1/' *.mkv
Breaking each part of the command down we have:
's/
= substituteepisode
= search for 'episode' string in original file(\d+)
= match 1 or more digits from earlier/
= end of search string, start of substitute stringS01E
= insert this string, replacing "episode"$1
= insert digits from(\d+)
/'
= end of substitute string*.mkv
= wildcard '*' symbol takes anything after 'episode 1' and inputs it for any mkv file type
The -n
argument shows you a preview of the changes to relevant files in the directory. Remove it and repeat the command to execute renaming your files. To learn more about the rename command, type rename -man
to bring up the manual.