I recovered deleted videofiles from sd-card and now I cannot sort them by date.

I can see "encoded date" with mediainfo filename.

How can I use the "encoded date" to sort videos, even rename them according to that date or better yet, rewrite "modified date" to file properties?


Assuming the line of output you have looks something like this (the date format does not matter):

Encoded date               : 2016-11-20

You could rename the files as their dates with a little script...

i=0; for f in *; do printf -v new "$(mediainfo "$f" | sed -nr 's/Encoded date\s+: (.*)/\1/p')-%02d.mp4" "$((++i))"; echo mv -v -- "$f" "$new"; done

I am giving them a final number to ensure files with the same date don't end up with exactly the same name, which would cause some to be overwritten. New filenames will be 2016-11-20-01.mp4 etc or whatever the date format from "Encoded date" is for you. Remove echo after testing to actually rename the files. More readable version:

for f in *; do 
   printf -v new "$(mediainfo "$f" | sed -nr 's/Encoded date\s+: (.*)/\1/p')-%02d.mp4" "$((++i))"
   echo mv -v -- "$f" "$new"


  • i=0 start iterating from 0
  • for f in * for all files in the current directory (replace with appropriate path or glob if necessary)
  • printf -v new format the new name like this
  • $(mediainfo "$f" | sed -nr 's/Encoded date\s+: (.*)/\1/p') extract the date info from the Encoded date field
  • -%02d.mp4" "$((++i))" add a number and extension to the end of each filename
  • mv -v -- "$f" "$new" rename the files

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.