New
#1
Batch file that replaces a filename in a txt file
I've got a task that I need to repeat 100 times in a CAD program.
I've written a small script in the CAD program that takes a model and does a bunch of things to it, saves it, and closes it. (That part is taken care of, but I want to automate it)
That script is written in a text file. But it's specific to that model.
What I want to do is write a Batch file that will:
1. Look into a folder and put the list of files in a variable or list.txt
2. Replace "filename" in my script with the first file in the variable/list.txt
3. Run my script
4. Select the next "filename" in the variable/list.txt
5. Repeat 2-4 until there are no more files left
Thank you very much for your time
I've never written a batch before, so please bear with me.
What I've got so far, and commented to finish what I want to do but don't know how:
[CODE]
@ECHO OFF
REM Prompts user for the directory
set /p pathName=Enter the File Path of the folder:
REM Get file names and store in a text file
dir /s /b "pathName*.*">"list.txt"
REM Count number of files in list="numfile", set number of loops
REM SET i=1, For i to "numfile" DO
REM Take 1st file from list and store in variable "filename"
REM Put "filename" in script
REM Run script
C:\fileLocation\script
REM Close script
Close C:\fileLocation\script
REM Goto "filename" i+1
REM Repeat Put/Run/Close/Goto until done