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.
batch script reading file content
Name: starp Date: December 14, 2008 at 13:00:22 Pacific OS: AMD CPU/Ram: Core 2 dual Product: Compaq / DFDSFDS
Comment:
Hi
I need a batch script which will read file content till a certain character, rename file with the original file name_content read.
Name: Judago Date: December 14, 2008 at 17:25:05 Pacific
Reply:
What type of file is it? If it contains any binary that isn't plain text then it won't work with plain batch.
Also what os is this batch intended for?
0
Response Number 2
Name: starp Date: December 14, 2008 at 20:47:44 Pacific
Reply:
hi
Os is windows 2000 professional text is plain text
thanks
0
Response Number 3
Name: Judago Date: December 14, 2008 at 21:51:08 Pacific
Reply:
This may do it, though it has no regard for blank lines and will leave them out. Where the script calls for x substitute your character("!line:x=!" and if "!line:~0,1!"=="x"). I have also prefixed the ren and move commands with echo for testing purposes, I suggest you leave them their until you are sure it does what you want.
@ECHO OFF setlocal for /f "usebackq delims=" %%a in ("your text file.txt") do ( set line="%%a" SETLOCAL ENABLEDELAYEDEXPANSION set line=!line:~1,-1! if "!line:x= !"=="!line!" ( echo !line!>>newtextfile ) else ( call :partline goto finish ) SETLOCAL DISABLEDELAYEDEXPANSION ) goto :finish
:partline if not defined line if defined pl (echo !pl!>>newtextfile&&goto :eof) else goto :eof if "!line:~0,1!"=="x" echo:!pl!>>newtextfile&&goto :eof set pl=!pl!!line:~0,1! set line=!line:~1! goto partline :finish ren "your text file.txt" "your text file.txt name_content read" move newtextfile "your text file.txt name_content read" pause
Summary: Hi! I would like to read file contents from a text file and display it using a batch loop. I had try this method but it seem like did not work. for /F "delims=" %%a in ("fileL.txt") do ( @echo %%a ) ...
Summary: I need to add to an existing VBS script - to read the contents of a CSV file and locate specific data, then the check the date to see if it matches the current date. Based on what it finds, it needs ...
Summary: I am working on a batch script that would update 7 different file servers that run the exact same application. The servers have identical directory structures. My goal is to create a mirrored direct...