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 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've asked a few questions which have touched around this issue, but I've been
I have a small gallery website but the amount of images in directory differs
Take the following code snippit: f = open(/mnt/remoteserver/bar/foo.bin, O_RDONNLY); while (true) { byteseread =
I have a clean installation of Windows XP (Professional, Version 2002, Service Pack 3)
I'm trying to make a small game using both SFML and Box2D. I have
So, I'm trying to use heat to generate fragments for the files in my
We have a Java application with a particular module that checks if a temporary
While fiddling around to try to automate some process, I ran into this seemingly
I have a current build process which does a .NET build using MSBuild and
I'm using a library, which I've loaded into GHCI. From the names of the

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.