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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:50:01+00:00 2026-06-17T07:50:01+00:00

I am a novice to python scripting. I have a script that I am

  • 0

I am a novice to python scripting. I have a script that I am hoping to run on all files in a directory. I found very helpful advice in this thread. However, I am having difficulty in determining how to format the actual script so that it retrieves the filename of the file that I want to run the script on in the command prompt, i.e. “python script.py filename.*” I’ve tried my best at looking through the Python documentation and the forums in this site and have come up empty (I probably just don’t know what keywords I should be searching).

I am currently able to run my script on one file at a time, and output it with a new file extension using the following code, but this way I can only do one file at a time. I’d like to be able to iterate over the whole directory using ‘GENE.*’:

InFileName = 'GENE.303'

InFile = open(InFileName, 'r') #opens a pipeline to the file to be read line by line

OutFileName = InFile + '.phy'

OutFile = open(OutFileName, 'w')

What can I do to the code to allow myself to use an iteration through the directory similar to what is done in this case? Thank you!

  • 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-17T07:50:02+00:00Added an answer on June 17, 2026 at 7:50 am

    You are looking for:

    import sys
    InFileName = sys.argv[1]
    

    See the documentation.

    For something more sophisticated, take a look at the optparse and argparse modules (the latter is preferable but is only available in newer versions of Python).

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

Sidebar

Related Questions

Python novice here. I am using python2.7.2 on Windows7. I have installed the PyWin32
I'm a novice Python user trying to do something that I think should be
I am a novice to Python and have started to write my first module
All right, I'm a novice at python, and here's the snippet of code in
I have a program that processes files and returns another file as output. When
I am a novice programmer in python. I'm currently constructing a class that parses
I have one little problem with my python knowledge (novice  ). The thing
My python level is Novice. I have never written a web scraper or crawler.
A question from a complete Python novice. I have a column array where I
I am a programming (and Python) novice. I am unable to run any python

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.