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

  • Home
  • SEARCH
  • 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 814421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:31:08+00:00 2026-05-15T01:31:08+00:00

i have a directory with around 1000 files….i want to run a same code

  • 0

i have a directory with around 1000 files….i want to run a same code for each of these file…

my code requires the file name to be inputted.

i have written code to copy the information of one into other in other format…
please suggest a method to copy all 1000 files one by one without need to change the file name every time

and i have a field serial_num which need to be continous i.e if 1st file has upto 30 then while coping other file it should continue from 30not from 0 again

require help

thanks..

from string import Template
from string import Formatter
import pickle
f=open("C:/begpython/wavnk/text0004.lab",'r')
p='C:/begpython/wavnk/text0004.wav'
f1=open("C:/begpython/text.txt",'a')
m=[]
i=0
k=f.readline()
while k is not '':
    k=f.readline()
    k=k.rstrip('\n')
    mi=k.split(' ')
    m=m+[mi]
    i=i+1

y=0
x=[]
j=1
t=(i-2)
while j<t:
    k=j-1
    l=j+1
    if j==120 or j==i:
       j=j+1
    else:
        x=[]
        x = x + [y, m[j][2], m[k][2], m[l][2], m[j][0], m[l][0], p]
        y=y+1
        #f1.writelines(str(x)+'\n')
        for item in x:
            f1.write(str(item)+'   ')
        f1.write(str('\n'))
        j=j+1

f.close()
f1.close()

my code…..

and i have files name in series like text0001…..text1500.lab and want to run them at a time without need to call them everytime by changin name

enter code here
  • 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-15T01:31:09+00:00Added an answer on May 15, 2026 at 1:31 am

    You could take a look at the glob module as well. It’s this easy:

    import glob
    list_of_files = glob.glob('C:/begpython/wavnk/*.lab')
    

    And yes, it works on windows as well.
    However, it only finds the matching files, doesn’t read them or anything.

    By the looks of your code example, you may or may not be interested in the python
    csv module as well.

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

Sidebar

Related Questions

i have this inside my site.css file (in the COntent directory) body { width:
I need to index around 10GB of data. Each of my documents is pretty
I have a few situations where I need to list files recursively, but my
We have many old snapshot views lying around and I need to find out
I have a Python module which uses some resources in a subdirectory of the
I have a client that's utilizing a windows service I wrote that polls a
OSGi seems to have an excellent benefit of having small deployable artifacts by not
I have a website where an admin can login and upload photos. All the
Reading around, the svn:ignore command seems to work one of two ways: If the
I'm getting the following error when Rails tries to render my layout located in

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.