I am using FFmpeg I'd like to create an mp4 using an image sequence.

But the images are not named sequentially, like 1, 2, 3, 4... Instead they are named with a time stamp in the form yyyy-mm-dd-mm.

How can I create a script to achieve this?

  • Which operating system?
    – Gyan
    Dec 23, 2015 at 4:21
  • The windows~~~~
    – kksky
    Dec 23, 2015 at 4:32
  • @Mulvya Since he mentioned PowerShell, I assume that's Win7 or higher. May 24, 2016 at 7:29
  • I don't see any mention of Powershell or Windows by the OP.
    – Gyan
    May 24, 2016 at 7:47

2 Answers 2


You can do it with scripting by renaming the files. I don't have a Windows machine at hand at the moment so I can't test this but this is what I would do in power shell:

First navigate to the directory containing the image sequence, then

mkdir sorted_images;
Get-childItems *. jpg | sort-object date | %{
Cp $_ (".\sorted_images\image_{0}.jpg" -f ($serial.toString("00000")));

That script should copy all the jpg images in the current folder to a new folder and rename them with a five digit serial number. Try it out on some test images first because I haven't tested it myself.


It's rather a powershell-specific question than FFmpeg, but here you go:

ffmpeg -i <input> <some_encoding_options> -f mp4 "my_filename_"$(get-date).ToString("yyyy-MM-dd_HH-mm")".mp4"

Change the parameter of ToString to whatever you want, you can find more info about PS date formatting syntax here.

A little cheatsheet (all of these have leading zeroes):

  • yyyy year
  • MM month
  • dd day
  • hh hour in 12-hour format
  • HH hour in 24-hour format
  • mm minute

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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