Posted by Tony Diaz on May 07, 2008 at 15:23:38:
In Reply to: Doing a DOS DIR based on a txt file and echoing some info to a log if found. posted by Tony Diaz on May 07, 2008 at 12:23:07:
I figured out the search and echo thing.
Now, if I could only echo either the 8.3 full filename or capture the actual extension of the file from the DIR command, I will set.
Bye the way...
The content of the text file which I search by is only the file's name, not its extension. I need to capture what file type is actually stored on the RAID.
Any takers?
: Every once in a while I need to find hundreds of lost files that reside on a RAID.
: So I do DIR filename. /S and if found I update a database with the Drive location and what not. That works fine. It's just having to do it serveral hundred times a week to keep the db accurate that bugs me.
: So, I created a batch file to read a txt file and with the FOR command, do a DIR /S on each entry and echo the results to a log file. No biggy!
: But, now I want to take it a step further. I want to know how to only do the ECHO to the log on the files that are found with the DIR /S command from the list pulled from the FOR command. Here is what I have tried.
: cls
: echo off
:
: SET DRIVE=C:\
: SET PATH=%CD% %SHARE%
: SET SHARE=IMAGE1
: SET EXT=*
: IF (DIR (FOR /F "tokens=1" %%A IN (c:\FILEIN.TXT))
: %%A.%EXT% /S) ERRORLEVEL 0 ECHO %%A %PATH% >> FILEOUT.TXT
: ... and I get a "FOR was unexpected at this time."
: Any pointers?
: Thanks.
: JD