Computing.Net > Forums > Windows 2000 > nested loop in batch file not working

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.

nested loop in batch file not working

Reply to Message Icon

Name: maya_zakry
Date: November 2, 2009 at 19:12:04 Pacific
OS: Windows XP
Subcategory: General
Tags: for loop, batch
Comment:

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
)



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: November 7, 2009 at 14:54:28 Pacific
Reply:

What is in Tools.txt ?


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

M2


0

Response Number 2
Name: maya_zakry
Date: November 10, 2009 at 00:39:59 Pacific
Reply:

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


0

Response Number 3
Name: Mechanix2Go
Date: November 10, 2009 at 04:30:26 Pacific
Reply:

What's the prob/error?


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

M2


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: nested loop in batch file not working

Help files not working www.computing.net/answers/windows-2000/help-files-not-working/30242.html

Creating Folder in Batch File??? www.computing.net/answers/windows-2000/creating-folder-in-batch-file/60537.html

BATCH FILE: loop inside a for loop www.computing.net/answers/windows-2000/batch-file-loop-inside-a-for-loop/65112.html