Comparing directory paths

February 6, 2010 at 01:08:25
Specs: Windows XP, 2GB
Hi

I am trying to write a script that runs through a list of directory paths (dir.txt) and picks out the path, does a check on the date modified on the file (from the path) against the current date (Today). If it matches, it says OK.

My code so far:

for /f "tokens=1" %%i IN ('dir /tw "C:\Ada\Ada1.txt" ^| find /i "Ada1.txt"') do set %ADA1=%%i
IF %DAY%==%ADA1% (ECHO ADA1 OK!) ELSE (ECHO ADA1 Not ok!)

However I need it to go through dir.txt and pick up the directory paths and assign the variables itself, and not me having to do that for each path. On a side note, I would also prefer to have the actual filename as the variable name.

Thanks in advance!


See More: Comparing directory paths

Report •


#1
February 7, 2010 at 06:59:08
UNTESTED:

Just creating a loop around what you have, reading dir.txt and using the variable got from that in the inner loop :

@echo off
setlocal enabledelayedexpansion

for /f %%f in (dir.txt) do (
set p_path=%%f
for /f "tokens=1" %%i IN ('dir /tw "!p_path!\Ada1.txt" ^| find /i "Ada1.txt"') do set %ADA1=%%i
IF %DAY%==%ADA1% (ECHO ADA1 OK!) ELSE (ECHO ADA1 Not ok!)
)


Report •
Related Solutions


Ask Question