I had to recover a bunch of movie files from my external HDD due to filesystem corruption and used photorec
to do so. Now all my files have random names like f00000.avi
. We are talking about 1000+ movies here, so renaming them manually would be pretty tedious. As I understand, most movie files have their titles stored inside the header as well, so is there a way to quickly rename a bunch of files by replacing the random names by the title of the movie?
Add a comment
|
1 Answer
You can try with mediainfo:
mediainfo f00000.avi
To rename all .avi files in the current directory, run:
for f in *.avi;do title=$(mediainfo $f|grep -i "movie name"|cut -d":" -f2);mv -v "$f" "$title";done
Install mediainfo using the command: sudo apt-get install mediainfo
-
In the off chance the file doesnt have a title in mediainfo what would happen if I run that script. Would it get an empty name? Feb 17, 2015 at 23:15
-
1