Bat file to check for multiple files

May 21, 2009 at 10:16:22
Specs: Windows XP
Hi all -
Need a little help. Attempting to write a batch file to check for and delete multiple files, outputting to a log file after anything is found.

Here's what I have so far:

echo off
setLocal EnableDelayedExpansion

echo Checking for files >> C:\found.log
for /f "tokens=* delims= " %%a in (list.txt) do (
set /a N+=1
set f!N!=%%a
if exist f!N! echo f!N! was found >> C:\found.log

the phrase "checking for files" gets appended to the log, but it never lists any files it may have found. I want to get this part up and running before I add in the delete command. Where am I going wrong?

See More: Bat file to check for multiple files

Report •

May 21, 2009 at 10:34:38
I don't know what you have planned for f!N! but to check for the existence of a file in the lilst:

for /f "tokens=* delims= " %%a in (list.txt) do (
if exist %%a echo %%a was found >> C:\found.log

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


Report •

May 23, 2009 at 05:45:07
Thank you. Just what I was looking for. :)

Report •

Related Solutions

Ask Question