Python Forum
Creating multiple folders and other questions
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating multiple folders and other questions
#1
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/

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 Smile
Reply


Messages In This Thread
Creating multiple folders and other questions - by coder2be - Aug-19-2018, 05:53 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  sub-folders in folders from text line jenost 1 1,595 Mar-31-2020, 07:16 AM
Last Post: ndc85430
  Creating multiple lists from file without long for loop Curtnos 2 4,498 Jan-28-2018, 09:11 AM
Last Post: Gribouillis
  Netmiko - add multiple files, from different folders to mail. tomikovaknin 5 5,389 Nov-26-2017, 12:55 PM
Last Post: heiner55
  Discord bot that asks questions and based on response answers or asks more questions absinthium 1 43,663 Nov-25-2017, 06:21 AM
Last Post: heiner55
  Creating folders dynamically with year/month/date sritsv 0 6,396 Oct-16-2017, 03:44 PM
Last Post: sritsv
  Creating multiple text fies from new url retrieve results wmc326 1 3,152 Jul-13-2017, 10:57 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020