Skip to content

Instantly share code, notes, and snippets.

@steveway
Forked from glad1couldkek/auto_sorter.py
Created October 10, 2016 15:38
Show Gist options
  • Select an option

  • Save steveway/4c8a13ec8754e7bdd78c71b114bfa516 to your computer and use it in GitHub Desktop.

Select an option

Save steveway/4c8a13ec8754e7bdd78c71b114bfa516 to your computer and use it in GitHub Desktop.
import time
import os
dirdl = '/home/Anon/Downloads/'
dirp = '/home/Anon/Pictures/'
dirv = '/home/Anon/Videos/'
dird = '/home/Anon/Documents/'
dirm = '/home/Anon/Music/'
dirs = [dirp, dirv, dird, dirdl, dirm]
while True:
time.sleep(10)
for u in dirs:
os.chdir(u)
items = os.listdir(u)
for i in items:
if i.endswith('jpg') or i.endswith('png'):
os.rename(u + i, dirp + i)
elif i.endswith('webm') or i.endswith('mp4'):
os.rename(u + i, dirv + i)
elif i.endswith('mp3'):
os.rename(u + i, dirm + i)
elif i.endswith('pdf') or i.endswith('epub'):
os.rename(u + i, dird + i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment