1

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?

1 Answer 1

3

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

2
  • 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
    No, you will get this error message "No such file or directory".
    – Panta
    Feb 18, 2015 at 6:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .