Skip to content

Instantly share code, notes, and snippets.

@subnomo
Last active August 29, 2015 14:12
Show Gist options
  • Save subnomo/f84e6848d6a4ec71932c to your computer and use it in GitHub Desktop.
Save subnomo/f84e6848d6a4ec71932c to your computer and use it in GitHub Desktop.
Simple Python script that separates gifs from other image types. The script deletes itself on completion.
import os
count = 0
for filename in os.listdir('.'):
if filename == 'separateGifs.py':
continue
elif os.path.isdir(filename):
continue
if filename[-3:] == 'gif': # If it's a gif, stash in gifs folder
count += 1
if not os.path.exists('gifs'):
os.makedirs('gifs')
print("Moving " + filename)
os.rename(filename, './gifs/' + filename)
if count == 0:
print("No gifs to move!")
else:
print("Done!")
os.remove('separateGifs.py')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment