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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:32:37+00:00 2026-06-11T21:32:37+00:00

I have a python script and I wrote it such that it will generate

  • 0

I have a python script and I wrote it such that it will generate an output file to a new directory called test using these two lines:

self.mkdir_p("test") # create directory named "test"
file_out = open("test/"+input,"w")

and the mkdir_p function is as follow:

def mkdir_p(self,path):
    try:
        os.makedirs(path)
    except OSError as exc:
        if exc.errno == errno.EEXIST:
            pass
        else: raise

Now, I have all the files that I would like my script to run on stored in directory called storage, and my question is, how can I write a script such that I can run all the files in storage from my home directory(where my python script is located), and saved all the output to the test directory as I coded in my python script?

I did a naive approach in bash like:

#!/bin/bash

# get the directory name where the files are stored (storage)
in=$1

# for files in (storage) directory
for f in $1/*

do

  echo "Processing $f file..."
  ./my_python_script.py $f

done

and it didnt work and threw IOError: No such file or directory: 'test/storage/inputfile.txt'

I hope I explained my problem clear enough.

Thanks in advance

  • 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-06-11T21:32:38+00:00Added an answer on June 11, 2026 at 9:32 pm

    $f is storage/inputfile.txt and Python prepends test/ to that, then complains because test/storage does not exist. Create the directory, or strip the directory part before creating the output file name.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a python script running on a small server that is called in
I have a Python script that is using some closed-box Python functions (i.e. I
I have a file called pids.txt that contains lines, such as the following: 123
I wrote a Python script that I need to have installed on Windows Server
I have a Python script that loads a web page using urllib2.urlopen , does
I have a python script that runs a program, which generates few .exe files
I have a python script that I want always to run in the background.
I have a Python script that makes use of 'Print' for printing to stdout.
I have a python script using the boto library on ec2 instance which is
I have a Python script that needs to issue a number of shell commands.

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.