Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 514095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:29:21+00:00 2026-05-13T07:29:21+00:00

I am creating a script to create new folder hierarchies for a friend of

  • 0

I am creating a script to create new folder hierarchies for a friend of mine. There are around a thousand clients, so a script would save a ton of time. I have everything almost working, the part I don’t have is this.

yearList = os.listdir(driveLetter + clientName)
for year in yearList:
    os.chdir(year)
    os.mkdir('Folder One')
    os.mkdir('Folder Two')
    os.mkdir('Folder Three')

Under this, are creations for sub folders, like so:

# Create folders under 'Folder One'
    os.chdir(driveLetter + clientName + '\\' + year + '\Folder One')
    os.mkdir('Sub Folder One')
    os.mkdir('Sub Folder Two')

2005 is the first element in the list of yearList. This runs fine for 2005, but I get this error:

WindowsError: [Error 2] The system cannot find the file specified: '2006'

This would really help my friend out, so I am pretty motivated to do it (And pretty[read: very] new to programming)

Thanks for any assistance that can be provided

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T07:29:21+00:00Added an answer on May 13, 2026 at 7:29 am

    In the for year in yearList loop you change to the year’s subdirectory, but probably never leave it again. So in the first iteration you enter the “2005” subdirectory and in the second iteration you are still in that subdirectory. Then you get the error that there is no “2006” directory (in the current “2005” directory).

    You can work around that by leaving the subdirectory again at the end of the loop:

    for year in yearList:
        os.chdir(year)
        ...
        os.chdir('..')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a bash script to create new EC2 instances and then upload a
I have simple table creating script in Postgres 9.1. I need it to create
I'm creating a script to pull a video off the web, create an image
We're creating an XML API for Joomla that allows partner sites to create new
Call me a 'n00b', but I am new to creating Script Controls. I want
I have a migration that runs an SQL script to create a new Postgres
I am implementing a shell script which will create a new self signed certificate
I am creating a SQL script file in MySQL. The script simply creates a
I am creating a bash script for generating certificates. The openssl command that creates
I've created a small script to test creating my own help based powershell and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.