Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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

@echo off
setLocal EnableDelayedExpansionfind "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

@echo off
setLocal EnableDelayedExpansionfor /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

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?

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 :EOFHere the drawback is the need to perform the whole file parsing even if the target is achieved.

![]() |
![]() |
![]() |

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