Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

Batch parse help

Original Message
Name: skakkola
Date: October 16, 2007 at 03:20:30 Pacific
Subject: Batch parse help
OS: win xp
CPU/Ram: 512
Model/Manufacturer: intel
Comment:
Hello,
I have a txt file:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML>
<HEAD>
<TITLE>FTP Listing of /xx/xxx/xxx/xx/ at xxx.xxx.xxx</TITLE>
<BASE HREF="ftp://xxx/wxx/xxx/xxx/xx/">
</HEAD>
<BODY>
<H2>FTP Listing of /xx/xxxx/xxx/xx/ at xxxx.xxx.xxx</H2>
<HR>
Parent Directory

<PRE>
Oct 10 2007 19:54 Directory images
Apr 25 2007 00:00 109153 x200715.zip
May 02 2007 00:00 106609 x200716.zip
May 09 2007 00:00 101234 x200717.zip
May 16 2007 00:00 58686 x200718.zip
May 23 2007 00:00 35036 x200719.zip
May 30 2007 00:00 40317 x200720.zip
Jun 06 2007 00:00 47291 x200721.zip
Jun 13 2007 00:00 80062 x200722.zip
Jun 20 2007 00:00 49223 x200723.zip
Jun 27 2007 00:00 51423 x200724.zip
Jul 04 2007 00:00 69741 x200725.zip
Jul 11 2007 00:00 57379 x200726.zip
Jul 18 2007 00:00 67033 x200727.zip
Jul 25 2007 00:00 44308 x200728.zip
Aug 01 2007 00:00 46946 x200729.zip
Aug 08 2007 20:09 58157 x200730.zip
Aug 16 2007 06:05 74215 x200731.zip
Aug 22 2007 20:07 74415 x200732.zip
Aug 29 2007 20:08 49555 x200733.zip
Sep 05 2007 20:07 30297 x200734.zip
Sep 12 2007 20:05 46637 x200735.zip
Sep 20 2007 08:06 43482 x200736.zip
Sep 26 2007 20:13 46957 x200737.zip
Oct 03 2007 20:11 46751 x200738.zip
Oct 10 2007 20:06 68676 x200739.zip
</PRE>

I need the number of the first file:
here the first file is x200715.zip
I need the 15!!!
please help


Report Offensive Message For Removal


Response Number 1
Name: Mechanix2Go
Date: October 16, 2007 at 03:46:43 Pacific
Subject: Batch parse help
Reply: (edit)
@echo off
setLocal EnableDelayedExpansion

find "zip" < my.txt > ziplist

for /f "tokens=* delims= " %%a in (ziplist) do (
if not !N!'==' goto :eof
echo %%a | find "zip" > nul
if not errorlevel 1 (
set str=%%a
set str=!str:~-6!
set N=!str:~0,2!
)
echo number of the first zip is !N!
)



=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal

Response Number 2
Name: skakkola
Date: October 16, 2007 at 04:04:11 Pacific
Subject: Batch parse help
Reply: (edit)
Thankx, but I get incorrct syntax error...

Report Offensive Follow Up For Removal

Response Number 3
Name: Mechanix2Go
Date: October 16, 2007 at 04:30:26 Pacific
Subject: Batch parse help
Reply: (edit)
@echo off
setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in ('find "zip" ^< my.txt') do (
if not !N!'==' goto :eof
set str=%%a
set str=!str:~-6!
set N=!str:~0,2!
echo number of the first zip is !N!
)



=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal

Response Number 4
Name: skakkola
Date: October 16, 2007 at 06:41:53 Pacific
Subject: Batch parse help
Reply: (edit)
That's good, thakx,
but I need to use it IN another script, so that the set 'setLocal EnableDelayedExpansion' is not good...
Is there a way to do it without this option?

Report Offensive Follow Up For Removal

Response Number 5
Name: IVO
Date: October 16, 2007 at 07:58:45 Pacific
Subject: Batch parse help
Reply: (edit)
Salve simone,

@echo off
Set N=
for /f "tokens=*" %%a in ('find "zip" ^< my.txt') do (
Call :PARSE %%a)
GoTo :EOF

:PARSE
If not %N%'==' GoTo :EOF
set str=%*
set str=%str:~-6%
set N=%str:~0,2%
echo number of the first zip is %N%
GoTo :EOF

Here the drawback is the need to perform the whole file parsing even if the target is achieved.


Report Offensive Follow Up For Removal


Response Number 6
Name: skakkola
Date: October 16, 2007 at 08:22:33 Pacific
Subject: Batch parse help
Reply: (edit)
Grazie Ivo, and thanks Mechanix2Go!!!

it works!! (both)


Report Offensive Follow Up For Removal



Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Batch parse help

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




CPU and Graphics Upgrade Questions

VIRUS ALERT in Taskbar, HELP!

DSHUB24 Connection Problems

need help with dsl and dial up

novel 3.12


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC