Skip to content

Instantly share code, notes, and snippets.

@rickkk856
Forked from loisaidasam/rename_images.py
Created September 2, 2021 17:42
Show Gist options
  • Save rickkk856/8478fa41696d91ae25546c9776218888 to your computer and use it in GitHub Desktop.
Save rickkk856/8478fa41696d91ae25546c9776218888 to your computer and use it in GitHub Desktop.
Rename images for use by ImageMagick convert or ffmpeg convert
# Goes a little something like this:
import os
files = [ f for f in os.listdir('.') if os.path.isfile(os.path.join('.',f)) and f.endswith('.jpg') ]
for i, file in enumerate(sorted(files)):
os.rename(file, 'image%03d.jpg' % i)
# Now with them renamed you can do something like:
# convert image%03d.jpg[0-293] animated_gif.gif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment