Computing.Net > Forums > Disk Operating System > Read a text file into a batch pgm?

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Read a text file into a batch pgm?

Reply to Message Icon

Name: lotus
Date: January 4, 2002 at 14:55:52 Pacific
Comment:

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.



Sponsored Link
Ads by Google

Response Number 1
Name: BlueFire
Date: January 5, 2002 at 05:14:36 Pacific
Reply:

Lotus,

Do you mean like:

process C:\files
process C:\pix
...
process D:\OtherStuff

If that's what's needed, I can help.

BlueFire


0

Response Number 2
Name: Laurence
Date: January 5, 2002 at 05:17:57 Pacific

Response Number 3
Name: Laurence
Date: January 5, 2002 at 13:12:50 Pacific
Reply:


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 
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.


0

Response Number 4
Name: ah
Date: January 7, 2002 at 07:27:31 Pacific
Reply:

hehehe We normal people have no chance against the almighty Batch File Site... No matter what.


0

Response Number 5
Name: Laurence
Date: January 7, 2002 at 10:41:28 Pacific
Reply:


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.


0

Related Posts

See More



Response Number 6
Name: Parker
Date: May 13, 2002 at 08:44:34 Pacific
Reply:

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.


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Read a text file into a batch pgm?

Splitting a text file www.computing.net/answers/dos/splitting-a-text-file/15783.html

Read text file into variable www.computing.net/answers/dos/read-text-file-into-variable/16618.html

Add commands to text file, how? www.computing.net/answers/dos/add-commands-to-text-file-how/14102.html