Aug-19-2018, 05:53 PM
Hi all
As mentioned in an introduction post I am very new to Python.
My first goal is to create a program/code that will simply sorts files into respective folders.
Quick summary of what I want to achieve:
I want to create a program that moves files based on their extensions into specific folders.
A user would manually unzip 'a ton' of files into a folder.
The files have different extensions.
All of the files with the same extension need to be placed in the same folder.
Any file that is not in the list to be moved simple stays in the top folder, for example text files.
I've had a look at the os module tutorial below and was able to create the respective directories I need.
https://pythonprogramming.net/python-3-os-module/
However, surely a better approach would be to create all the subfolders in one go?
I tried:
Any ideas what I am doing wrong please?
Jumping the gun a little......any clues or suggestions on what to dabble with next to get files to move into folders?
Finally, once I have all the code correct, how do I package it into a tool that anyone can just run?
Thank you for any help and for your patience with a newbie
As mentioned in an introduction post I am very new to Python.
My first goal is to create a program/code that will simply sorts files into respective folders.
Quick summary of what I want to achieve:
I want to create a program that moves files based on their extensions into specific folders.
A user would manually unzip 'a ton' of files into a folder.
The files have different extensions.
All of the files with the same extension need to be placed in the same folder.
Any file that is not in the list to be moved simple stays in the top folder, for example text files.
I've had a look at the os module tutorial below and was able to create the respective directories I need.
https://pythonprogramming.net/python-3-os-module/
import os os.mkdir('Maps') os.mkdir('Sounds') os.mkdir('Music') os.mkdir('Textures')This worked just fine.
However, surely a better approach would be to create all the subfolders in one go?
I tried:
os.makedirs ('/Maps/Sounds/Music/Textures')It didn't error but it also didn't create these folders?
Any ideas what I am doing wrong please?
Jumping the gun a little......any clues or suggestions on what to dabble with next to get files to move into folders?
Finally, once I have all the code correct, how do I package it into a tool that anyone can just run?
Thank you for any help and for your patience with a newbie
