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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:02:27+00:00 2026-06-08T07:02:27+00:00

i have created a script and wanna it to loop through all the file

  • 0

i have created a script and wanna it to loop through all the file in a directory..
but i failed to do that..
i create another script to apply the script (change_content)..
here the code,

cd \input

for %%f in (*.txt) do (

            echo "%%~nf"
            "D:\deployment code\change_content" .\"%%~nf".txt
    )

change_content.bat

call :yesterday today -1
for /f "delims=" %%a in (%1) do (
set "val=%%a"
if "!val:~12,10!"=="0001-01-01" (
>> D:\temp\%1_changed.txt echo !val:~0,12!%day%!val:~22!
) else (
>> D:\temp\%1_changed.txtecho %%a     
)
)

My problem is i cant let the script to read the input file if i put it as variable. I can only put the actual file which not helpful in automate the process?
this is just part of the code where i point to the input and output direction..
just wondering what should i do at the for /f place..

Would be appreciate if anyone could help on this..thanks 🙂

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

    I understand your problem as what you listed in bold text above. The following should work, going from memory, but I cannot test it now as I am without a Windows computer now ( and happy I don’t have to have one with me ).

    If you are instersted in the main program looping portion, try this:

    setlocal eneabledelayedexpansion
    
    REM:: take \input as param from command line
    set top_folder=%~1
    set change_content="D:\deployment code\change_content.bat"
    
    for /f "eol=; tokens=1 delims=" %%t in ( 'dir /b !top_folder!\*.txt' ) do (
      REM:: the /b may or may not give yo the full path you need
      REM:: google this if I am wrong
    
      set file_name=%%~nt
      !change_content! !file_name!
    
    )
    

    If you are interested in the change_content portion, try this:

    setlocal enabledelayedexpansion
    
    REM:: change_content looping over file_name variable.
    set file_name=%~1
    for /f "eol=; tokens=1 delims=" %%f in ( 'type "!file_name!"' ) do (
      set line=%%f
      REM::  Do your thang in here with !line!.
    ) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a script that saves some files in the Documents directory of
I have created a script that reads from a CSV (or other dataset, but
I have created a script that will upload files to a general uploads folder,
I have created a Greasemonkey script that runs fine in the firebug editor, with
I have created an R script that it needs to load some libraries first.
I have created one ruby script that I want to run with some flags
My client have created a script in php+mysql that saves images directly in the
I have created script to find selectivity of each column for all tables. In
I have created the SQL script below that creates four tables and inserts data
I have created a script that analyzes a set of raw data and converts

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.