Last active
August 29, 2015 14:12
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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