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 4625594
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:17:43+00:00 2026-05-22T03:17:43+00:00

Since Im unfamiliar with Python I thought i’d come here. Anyways I have several

  • 0

Since Im unfamiliar with Python I thought i’d come here.

Anyways I have several Folders (lets say 20 folders)
Within each folder is more folders (lets say 5 per)
and within EACH one of these folders is another folder, and within THAT is a script I need to run.

The script is ran the same way ‘ie’:sh script.sh

Basically I need to run this script for each of these folders, problem is I have no clue how to step into each folder (that has the script) which is 4 levels down from the original folder.

So there are a total of like 120 scripts that need to be ran the same way (this script also returns a number for instance (1 for success, 0 for failure) that I need to record (shouldn’t be too hard to figure out)

What would be the best way to go about this? The Checking results I think I can figure out, but stepping through all these subfolders Im honestly not well versed in python to know about.

Just so everyones clear the folder structure is like this:
Top Level (20 or so folders)
 -->1 Below (5 or so Folders)
 ----->1 below one of these 5 folders (only 1 folder is contained)
 --------->1 below that one folder (here is where the script resides)

Don’t ask me why the folders are structured this way…..lol. This would be done in python 2 preferably.

  • 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-22T03:17:44+00:00Added an answer on May 22, 2026 at 3:17 am

    A bit overkill, but it should work:

    import os
    
    root = '/foo/'
    
    for directory, subdirectories, files in os.walk(root):
      for file in files:
         if os.path.splitext(file)[-1].lower() == '.sh':
           os.system('sh ' + os.path.join(directory, file))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Since the pages are stored in address_space within each inode, how does the background
Since CS3 doesn't have a web service component, as previous versions had, is there
Since the keyboard is the interface we use to the computer, I've always thought
To start off, I'd like to say I'm rather unfamiliar with the Windows linking
Since I'm new to coding and I'm trying to understand why here is a
Since i'm writing a game in RoR, i need to have a game loop
Since I started learning Objective-C and Cocoa, I've been wondering why they have chosen
Since HTA applications are hosted within MSHTA.exe how does one provide a manifest? Plus
Since google has failed me for the past 5-10 minutes I have a quick
We have several SQL Server databases containing measurements from generators that we build. However,

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.