Computing.Net > Forums > Programming > Bat file to check for multiple files

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Bat file to check for multiple files

Reply to Message Icon

Name: freezefire
Date: May 21, 2009 at 10:16:22 Pacific
OS: Windows XP
Subcategory: Batch
Comment:

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?



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: May 21, 2009 at 10:34:38 Pacific
Reply:

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.

M2


0

Response Number 2
Name: freezefire
Date: May 23, 2009 at 05:45:07 Pacific
Reply:

Thank you. Just what I was looking for. :)


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Bat file to check for multiple files

how to check for memmory leaks www.computing.net/answers/programming/how-to-check-for-memmory-leaks/4958.html

Bat file to check for file with current date www.computing.net/answers/programming/bat-file-to-check-for-file-with-current-date/18823.html

read from file to check for duplicates www.computing.net/answers/programming/read-from-file-to-check-for-duplicates/19032.html