Here is a quick Python tool i wrote.
So i was browsing 8chan and someone in /tech/ asked how to go about sorting a bunch of files. So i wrote this script for them. It's probably a little shitty, since i did this in 30 minutes but i would figure i would share regardless. As it might be educational or helpful to someoneone here.

#!/usr/bin/env python2.7

import os
import shutil

images = [".jpg", ".gif", ".png", ".tiff", "jpeg"]
videos = [".mkv", ".mp4", ".mpg", ".mpeg"]
binaries = [".exe", ".jar"]
archives = [".7z", ".zip", ".rar"]

def move(TYPE):
    files_to_move = []
    for root, dirs, files in os.walk("/"):
        for file in files:
            if file.endswith(tuple(TYPE)):
                files_to_move.append(os.path.join(root, file))
    return files_to_move

while True:
    print """Hey, wanna' move some files?


    choice = raw_input("Enter your choice: ")
    if choice == '1':
        if not os.path.isdir("/home/images/"):
            os.mkdir( "/home/images/", 4577 )
        result = move(images)
        for files in results:
                shutil.move(files, "/home/images/")
        print "[+]Done"

    elif choice == '2':
        if not os.path.isdir("/home/videos/"):
            os.mkdir( "/home/videos/", 4577 )
        result = move(videos)
        for files in results:
                shutil.move(files, "/home/videos/")
        print "[+]Done"
    elif choice == '3':
        if not os.path.isdir("/home/binaries/"):
            os.mkdir( "/home/binaries/", 4577 )
        result = move(binaries)
        for files in result:
                shutil.move(files, "/home/binaries/")
        print "[+]Done"
    elif choice == '4':
        if not os.path.isdir("/home/archives/"):
            os.mkdir( "/home/archives/", 4577 )
        result = move(archives)
        for files in result:
            shutil.move(files, "/home/archives/")
        print "[+]Done"
    elif choice == '5':
        print "[!]Unhandled option"

Also, yeah, i know os.walk is slow and my script doesn't include all image or video types but you can easily add more by adding it to the tuple for the respective filetypes.

So for instance if you want an extra image type you would do this.

images = [".jpg", ".gif", ".png", ".tiff", "jpeg", ".your_extension_here"]

That's basically it. I won't be publishing this to my github, this was just a quick exercise to help Anon on 8chan. Hope it helps you too.

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python Ebook Collection [89 Files] Insider 15 88,243 08-12-2021, 08:02 PM
Last Post: zzeuss
  NSA Python Training Insider 4 28,853 08-12-2021, 02:14 AM
Last Post: hworth
  What’s the issue here ? FancyBear 4 22,447 01-13-2021, 06:50 PM
Last Post: Vector
  Having an issue writing a python script with vim FancyBear 4 22,526 01-03-2021, 11:27 PM
Last Post: FancyBear