|
|
|
Batch Extract Text Lines One By One
|
Original Message
|
Name: DarkCyber
Date: January 4, 2008 at 12:49:39 Pacific
Subject: Batch Extract Text Lines One By OneOS: XPCPU/Ram: Intel |
Comment: Hi, I want to extract text line's one by one from a text file. line 1 line 2 line 3 line 4.... I hope someone knows
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: tonysathre
Date: January 4, 2008 at 14:28:19 Pacific
Subject: Batch Extract Text Lines One By One |
Reply: (edit)Okay...And do what with them? Just display them to STDOUT? type filename.txt "Computer security." — Oxymoron
Report Offensive Follow Up For Removal
|
|
Response Number 3
|
Name: DarkCyber
Date: January 4, 2008 at 15:00:53 Pacific
Subject: Batch Extract Text Lines One By One |
Reply: (edit)This is the script I want to use it for its called Findit.bat. The only problem is it can't open folders from the results. I made it because its faster than GUI search in xp pro. Sorry, for my bat English @echo off if %1x==x goto userinput if [%1]==[/?] goto help if %1==-? goto help if %1==? goto help goto next :help echo. echo Findit Beta 0.8 echo. echo Search For A File Or Map. echo. echo Findit (File) (Drive) - Example Findit game.exe A:\ echo Findit - Prompt For Userinput echo. goto end :userinput cls echo. echo Findit Beta 0.8 echo. echo Example: File.exe echo. set /p _name=Search File ?: cls echo. echo Presse Enter For Drive %~d0\ Or Add A Custom Drive. echo. set /p _drive=What Drive ?: if %_drive%x==x set _drive=%~d0\ cls echo. echo Find File(s): %_name% On Drive: %_drive% echo. dir %_drive% /a /s /b | find /i "%_name%">%temp%\output.txt for %%R in (%temp%\output.txt) do if %%~zR equ 0 echo Nothing found!>%temp%\output.txt type %temp%\output.txt del %temp%\output.txt echo. :again echo New Search ? echo. set /p _yn=[Y,N]?: if %_yn%==y goto userinput if %_yn%==n goto end goto again :next if %2x==x set _drive=%~d0\ if not %2x==x set _drive=%2 dir %_drive% /a /s /b | find /i "%1">%temp%\output.txt echo. echo Find File(s): %1 On Drive: %_drive% echo. for %%R in (%temp%\output.txt) do if %%~zR equ 0 echo Nothing Found!>%temp%\output.txt type %temp%\output.txt del %temp%\output.txt echo. goto end :end set _name= set _drive=
Report Offensive Follow Up For Removal
|
|
Response Number 4
|
Name: Razor2.3
Date: January 4, 2008 at 19:21:04 Pacific
Subject: Batch Extract Text Lines One By One |
Reply: (edit)The only problem is it can't open folders from the results. What? Do you want a window of the containing folder to pop up? Also, what's wrong with dir "%_drive%\%1" /s /b /a?
Report Offensive Follow Up For Removal
|
|
Response Number 5
|
Name: klint
Date: January 5, 2008 at 03:46:45 Pacific
Subject: Batch Extract Text Lines One By One |
Reply: (edit)DarkCyber, to answer your original question (not that it would be of any help), to read a file line-by-line use the FOR /F command. Since FOR /F has a lot of options, I suggest you type FOR /? and read the help screen carefully, and experiment with FOR /F's options until you understand how it works. To summarise, if you want to read each line into a variable use this: FOR /F "delims=" %%a in (filename.txt) do ( rem do things with %%a ) However, as Razor rightly said, you don't have to go through such lengths. Just give the filename in the dir /s command. For example, if you do dir /s C:\folder\file.txt it will search for file.txt in C:\folder and all of its subfolders. In fact, I use the dir/s command directly and don't bother with a batch file at all. The plain dir/s command gives me all I need. By the way, finding a file in explorer is slower because it also searches .zip and .cab archives for the file. If you don't want that, you can unregister the DLLs that deal with .zip and .cab files.
Report Offensive Follow Up For Removal
|
|
Response Number 6
|
Name: DarkCyber
Date: January 5, 2008 at 12:25:36 Pacific
Subject: Batch Extract Text Lines One By One |
Reply: (edit)@Razor2.3 Yes, I don't realy need it, but it popup in my mind and I like idea and want to build it. What wrong with dir %_drive% /a /s /b | find /i "%1 I don't no it worked for me with the FIND command. Your both right that dir /s is mutch shorter and faster. @klint I will lookup FOR command it will come to good use. Mabe al finish de script with popup folder, just for the building. Many thanx for both your help
Report Offensive Follow Up For Removal
|
|
Response Number 7
|
Name: DarkCyber
Date: January 5, 2008 at 14:45:56 Pacific
Subject: Batch Extract Text Lines One By One |
Reply: (edit)@Razor Sorry your right, I don't need the "find" part, dir /s /a /b c:\dos.txt does the trick. Thats my problem, talk firs think later bit of a nasty habit.
Report Offensive Follow Up For Removal
|
|
Response Number 8
|
Name: klint
Date: January 5, 2008 at 15:53:11 Pacific
Subject: Batch Extract Text Lines One By One |
Reply: (edit)DarkCyber, "Thats my problem, talk firs think later" that's the trait of a great manager, I was once told. (Though I think I should get my Dilbert manual out to check if that's true...)
Report Offensive Follow Up For Removal
|
Use following form to reply to current message:
|
|

|