Computing.Net > Forums > Disk Operating System > find data in a txt file with batch

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

find data in a txt file with batch

Reply to Message Icon

Name: uli_glueck
Date: November 3, 2003 at 01:07:40 Pacific
OS: NT 4
CPU/Ram: P II
Comment:

hello...
I try to find some data with a batch in a list of 350 pages like this:

directory of
O:\directory\

13.09.01 21:18 7.846.390 1.TIF
13.09.03 21:22 1.647.616 2.TIF

o:\dir\
13.09.01 21:15 18.296.710
4 Datei(en) 30.584.712 Bytes

Anzahl der angezeigten Dateien:
331 Datei(en) 3.123.111 Bytes 4.543.225.856 Bytes free

I need the second last line
and I need from some dates the full line; for example all of year 01.
I tried something like this in different versions:

FOR /f "delims=" %%a in ('find "03" c:\3_3\speicherTif.txt') do echo %%a

But I doesnīt really work.

thanks for any help
uli



Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: November 3, 2003 at 04:25:05 Pacific
Reply:

PLease, explain better your search criteria:

- what do you mean with "second last line"?
- what are the lines you like to retrieve with full data ?

Sorry, but your post left me confusing.


0

Response Number 2
Name: uli_glueck
Date: November 3, 2003 at 05:13:04 Pacific
Reply:

with second last line I mean the line who shows how many files and how many bytes the files need when typing the dir command:

files :331 Datei(en) 3.123.111 Bytes

From this lines

13.09.01 21:18 7.846.390 1.TIF
13.09.03 21:22 1.647.616 2.TIF

I want to search for example all of year 2001.

The reason is that we donīt have enough disk space so I want to find files wich are not used for longer time and burn it on CD and delete it from the file server.
With the DIR command I can just sort in every directory and have to check the list manually.

The line that shows me how many bytes the files use, I need for statistic.

Sorry about my english
uli


0

Response Number 3
Name: IVO
Date: November 3, 2003 at 07:27:44 Pacific
Reply:

Hi uli,

I am back and now I understand what you want to accomplish. The batch you find below should do the job, based upon your directives and lines sample. I tell you however the work could be fully automated and the reports better edited.

I tested the script using your sample, but if anytging goes wrong or you need more support post again.

To run type XScr FileName Year File_Out where FileName is your 350 pages list, year the Year and File-Out the file you want to hold the report (it may be CON or PRN i.e the screen and printer)

I hope this helps. Good work

@Echo Off

:: XSCR.BAT Syntax: XScr FileName Year File_Out

Echo.
If %1.==. (Echo File missing & GoTo :EOF)
If not exist %1 (Echo File "%~f1" not found & GoTo :EOF)
If %2.==. (Echo Year missing & GoTo :EOF)
If %3.==. (Echo Output missing & GoTo :EOF)

Echo Screning "%~f1" for %2 - Output to "%~f3"
Echo Screning "%~f1" for %2 - Output to "%~f3" > %3
Echo. >> %3
For /F "tokens=1-3* delims=. " %%A in (%1) Do (
If "%%C"=="%2" Echo %%A.%%B.%%C %%D >> %3
If "%%B"=="Datei(en)" Echo %%A %%B %%C.%%D >> %3)
Echo Processing completed


0

Response Number 4
Name: uli_glueck
Date: November 4, 2003 at 01:38:25 Pacific
Reply:

Hi Ivo,

thanks a lot. It works great.

Just

If "%%B"=="Datei(en)" Echo %%A %%B %%C.%%D >> %3

doesnīt work. It seems to be the same problem
I had with with For....
"Datei (en)" is at the end of each directory listed. (There are many in the list)
I just need the last line with "Datei(en)"
in the list.
(thats what I meant with second last in the list. ;-) )
I just know how to ignore the first x lines if I know how many lines they are.
Is there a possibility to search the last line of "Datei (en)" ?

greetings
uli



0

Response Number 5
Name: IVO
Date: November 4, 2003 at 01:55:52 Pacific
Reply:

Hi uli,

To get only the last Datei line substitute in the script the lines starting with

If "%%B"=="Datei(en)" Echo %%A %%B %%C.%%D >> %3)

with the following

If "%%B"=="Datei(en)" Set Datei=%%A %%B %%C.%%D)
Echo. >> %3
Echo %Datei% >> %3
Echo.
Echo Processing completed

That catches only the last line of your interest.


0

Related Posts

See More



Response Number 6
Name: uli_glueck
Date: November 4, 2003 at 23:06:23 Pacific
Reply:

Hi Ivo,

it works perfect!
thank you very much for help.

uli


0

Sponsored Link
Ads by Google
Reply to Message Icon

boot disk image Additional DOS commands



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: find data in a txt file with batch

delete a file using batch file www.computing.net/answers/dos/delete-a-file-using-batch-file/13939.html

Extract data form txt file in bat www.computing.net/answers/dos/extract-data-form-txt-file-in-bat/16535.html

how to write a string to a txt file www.computing.net/answers/dos/how-to-write-a-string-to-a-txt-file/11890.html