You are not logged in.

#1 09 Nov 2016 22:52

paul0041
Member
Registered: 19 Mar 2015
Posts: 21

simple loop problem

What am I missing here?

DelayedExpansion is enabled

The variable !FileList! is a text string with spaces for delimeters between each value like this:
ConfigureBIOSwithCCTK InstallPowerMgmtTasks ConfigureWakeOnLan


For some reason, the following loop only echos the first value in !FileList! instead of all 3 above.

For /F "Tokens=1 delims= " %%i IN ( "!FileList!" ) Do (
     set Downloadpkg=%%i
         echo Download %%i
)


Thanks ahead for any help!

Offline

#2 09 Nov 2016 23:03

ImAhNoBoDy
Member
Registered: 29 Dec 2015
Posts: 12

Re: simple loop problem

is it because of your token? You can try Tokens=* instead of 1

Offline

#3 14 Nov 2016 17:16

paul0041
Member
Registered: 19 Mar 2015
Posts: 21

Re: simple loop problem

No, that just results in the whole list being placed in the parameter %%i at once.  I need each unique item to be placed in %%i as the loop iterates.

Here is the whole thing:
I am trying to download a set of files by constructing a file list and then giving that list to a nested loop

So the outside loop should determine the package name
And the inside loop should use that package name (Token 1) to find the correct line in Directory.csv and then use token 2 and 3 to determine the file to be downloaded.

:CopyResources
For /F "Tokens=1 delims= " %%i IN ( "!FileList!" ) Do (
    set Downloadpkg=%%i
        For /F "Tokens=1-3 delims=," %%i IN ( 'findstr !Downloadpkg! %DownloadDestination%\Directory.csv' ) Do (
        VERIFY ON
        Copy %DownloadSourceHomeDirectory%\%%k\%%j %DownloadDestination% /y > nul
        VERIFY OFF
        )
)


Directory.csv is a list of package names, the file name and its directory name like this:
ConfigureBIOSwithCCTK,pushCCTKinstall.bat,CCTK
InstallPowerMgmtTasks,powerMgmt_Updater.bat,PowerMgmt

Currently the outside loop only returns the first token as expected.  In this case ConfigureBIOSwithCCTK.  Findstr finds it and the next line downloads the file, but when adding more packages to the list, only the first is found and downloaded.

Changing the outside loop to Tokens=* results in the first package being found and downloaded too but then Findstr can't find the other package names.

when %%i == ConfigureBIOSwithCCTK InstallPowerMgmtTasks
FINDSTR: Cannot open InstallPowerMgmtTasks


Does this make sense?  I know I'm missing something extremely simple...

Offline

#4 14 Nov 2016 17:39

paul0041
Member
Registered: 19 Mar 2015
Posts: 21

Re: simple loop problem

never mind.  I figured it out.

Offline

Board footer

Powered by