nested loop in batch file not working

November 2, 2009 at 19:12:04
Specs: Windows XP
Hi,
Im trying to do nested for below :-
1. loop out thru sharepoint
2. for every sharepoint, copy only recent files, for testing i just echo the most recent filename.

here what i came out and didnot work as i expected for 2 loop..

@echo off

For /F "tokens=1,2,3,4" %%a in (Tools.txt) Do (

echo %%a,%%b,%%c,%%d >> extract.txt

for /f "delims=" %%m in ('dir /od /a-d /b %%a\*.txt') do set recent=%%m

echo %%m >> recent.txt
)


See More: nested loop in batch file not working

Report •


#1
November 7, 2009 at 14:54:28
What is in Tools.txt ?


=====================================
Helping others achieve escape felicity

M2


Report •

#2
November 10, 2009 at 00:39:59
Ok, i managed to get this work after separating it in function. dunno why, but i have 2nd requirement. I need to get 2nd most recent file, if the recent file return file less than 500kb..

Tool.txt contains below
DS15 \\PGO-desk1.ar.com\LogFile\DS\DS15\20090901 LC14 ds26

FOR /F "TOKENS=1,2,3,4 DELIMS= " %%a IN (Tools.txt) DO (
net use x: %%b
if exist x: (
call :recent %%b
)

:recent
for /f "delims=" %%m in ('dir /od /a-d /b %~1\*.txt') do set recent=%%m
if not "%recent%" =="" (
copy "c:\keke\head.txt" + "%~1\%recent%" "c:\keke\new\%recent%"
)
if "%recent%" =="" (echo "No Log available" >> c:\keke\new\bad.txt )
pause
goto :eof


Report •

#3
November 10, 2009 at 04:30:26
What's the prob/error?


=====================================
Helping others achieve escape felicity

M2


Report •

Related Solutions


Ask Question