Posted by Tony Diaz on May 07, 2008 at 12:23:07:
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