Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I need to write a batch file that will loop thru a list of directory names from a text file. And use the directory names as variables.

Lotus,
Do you mean like:
process C:\files
process C:\pix
...
process D:\OtherStuffIf that's what's needed, I can help.
BlueFire

Try this batch and *study* the helping
files created in the %temp% directory.Watchout for wrapped lines!!
:: deltmps.bat
@ECHO off
IF "%1"=="ReCuRs" GOTO recurs
%COMSPEC%/e:4096/K%0 ReCuRs
GOTO end:recurs
PROMPT DEL %=%
ATTRIB.EXE c:\*.tmp -R -A -S -H /S
ATTRIB.EXE c:\*.tmp /S> %temp%.\test1.bat
pause
CTTY nul
%COMSPEC%/C%temp%.\test1.bat> %temp%.\test2.bat
CTTY con
::following line optional, ansi.sys required
::ECHO [2A
FIND.EXE "\" %temp%.\test1.bat
::DEL %temp%.\test2.bat
::FOR %%c in (CALL DEL) do %%c %temp%.\test1.bat
EXIT:end
::In order to do this procedure safely on
any file listing, you must change to
an empty sub-directory to the %temp%,
clear the %path% while the cloaked commandline runs, restoring the path,
and changing back to the original directory,
deleting the %temp% sub-directory.
=============
%COMSPEC%/C%temp%.\test1.bat>%temp%.\test2.bat
=============This batch will delete all *.tmp files on
c: when you uncomment the DEL and FOR lines.

You're right... I am not normal .
Thanks for the compliment. Hey, if you
can't beat 'em join 'em. But seriously,
there are people around more clever than
I, as far as batch programming is concerned... believe it or not.

I have a text file named demo.txt with the contents similar to this
c:\a\b\e\e.inp
c:\a\1\2\2.inp
c:\a\x\y\y.inp
c:\a\t\o\o.inp
c:\a\n\a\a.inp
As you can see they are the paths to files. I have round about 250 paths
like that in my demo.txt.Thanks
I'm trying to write a DOS batch file where in I have to do the following
1.My batch file should open the txt file
2.It should pick up the first line or first path
3.and change directory CD to the folder
4. From that directory should be able to just take the last folder name and pass it as parameter.
execute app <%1.inp -- app is our application.5.Now we have to loop back and pick up the 2nd line.
Note: I dont have to get the entire string each time as C:\a is common to
all the strings. I need to grab the path after c:\a in each line or rather
path.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |