File Organizer - Printable Version +- Support Forums (https://www.supportforums.net) +-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87) +--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18) +---- Forum: Python Programming Language (https://www.supportforums.net/forumdisplay.php?fid=32) +---- Thread: File Organizer (/showthread.php?tid=4901) |
File Organizer - uber1337 - 02-19-2010 This script I made will find all of the files of a certain extension and organize them into one folder. Just give it a folder to start with, a destination folder(for everything it finds), the extension you want (.mp3, .exe, .txt, .py, etc), then give it the depth of sub folders to look in. Giving it the depth basically tells it how many folders deep it need to search, i.e: If you want it to go this deep: /home/devin/Documents/Coding/Python/My_Projects/Under_Development/GUI You would need to give it a depth of 8, it acts like a spider kind of, it will search all possible directories within the given depth. If you are not sure just give it a depth like 20. Code: ############################### EDIT: Well this tool has been working out great for me so I took the time to make a GUI and a terminal interface. Here is the GUI version: Code: import glob, shutil And here is the terminal interface version, it works like this: python filename start destination extension depth here is an example, I have the file name as search.py: python search.py /home/devin /home/devin/Documents .ogv 2 In the example, "search.py" is the filename, "/home/devin" is the starting directory, "/home/devin/Documents" is the destination, ".ogv" is the extension, and "2" is depth. Here is the code: Code: import shutil, glob, sys If you have any questions feel free to ask. Edit: the indentation in the terminal one is fudged up, go ahead and tab "end" RE: File Organizer - derf2o9 - 02-19-2010 thx for the code man RE: File Organizer - Fallen - 04-05-2010 Glob comes in handy, however os.walk is definetly worth looking into, if you have not already. RE: File Organizer - C!RCU!T tr0jAn ☠ - 04-06-2010 Haha, this could be interesting to play around with. Thanks. Btw, how did you learn Python? PM me please. RE: File Organizer - BrainDeadFreak - 04-06-2010 Hmm I wish I knew Python. I have no clue what this says. RE: File Organizer - GameOver* - 04-06-2010 helpful code dude! thanks for share! |