Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- def create_subdirectories(base_directory, input_file):
- with open(input_file, 'r') as infile:
- for line in infile:
- # Remove newline characters from the directory name
- dir_path = line.strip()
- # Create the full path for the new subdirectory
- full_path = os.path.join(base_directory, dir_path)
- # Create the subdirectory if it doesn't already exist
- if not os.path.exists(full_path):
- os.makedirs(full_path)
- print(f"Created directory: {full_path}")
- else:
- print(f"Directory already exists: {full_path}")
- # Ask the user for the base directory
- base_directory = input("Please enter the base directory: ")
- # Replace 'input.txt' with your input file name containing the directory names
- input_file = 'input.txt'
- create_subdirectories(base_directory, input_file)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement