Computing.Net > Forums > Programming > Variable from A List File Part 2

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.

Variable from A List File Part 2

Reply to Message Icon

Name: einstein8
Date: October 4, 2008 at 22:42:27 Pacific
OS: XP
CPU/Ram: 1.8/2Gb
Product: Dell
Comment:

This is a lighter, easier to understand script than the first part. Judago had came about helping me out with it but for some reason, it still aint working. Hope you guys can help me out! - Marie

The script below is 100% working. What I want to do is for the variable isoissue to pick up the data from an external list.txt file. The list.txt would have the following:
item1
item2
item3

@echo off

Set "isoissue=item1"

Set "sourceDir=d:\edwin\work\autocopy\isometrics"
Set "TOLOCATION1Folder=d:\edwin\work\autocopy\TO_LOCATION1"
Set "TOLOCATION2Folder=d:\edwin\work\autocopy\TO_LOCATION2"

:: copy files TOLOCATION1Folder
For /F "Delims=" %%! in ('Dir "%sourceDir%\%isoissue%.i*" /b /s /a-d 2^>nul') do (@echo.%%! &(@xcopy "%%!" "%TOLOCATION1Folder%\" /i /y /h /f /c))

:: copy files TOLOCATION2Folder
For /F "Delims=" %%! in ('Dir "%sourceDir%\%isoissue%.i*" /b /s /a-d 2^>nul') do (@echo.%%! &(@xcopy "%%!" "%TOLOCATION2Folder%\" /i /y /h /f /c))


:done
title,Done.......

echo.&pause>nul

hopeless but trying



Sponsored Link
Ads by Google

Response Number 1
Name: einstein8
Date: October 4, 2008 at 22:50:23 Pacific
Reply:

This is Judago's suggestion but it doesnt work :( hope you can carry on from here and check whats wrong with it..

@echo off
title AUTOMATED ISO COPY

for /f %%g in (d:\edwin\work\autocopy\list.txt) do call :body %%G
goto :eof
:body
Set "isoissue=%1"

Set "sourceDir=d:\edwin\work\autocopy\isometrics"
Set "TOLOCATION1Folder=d:\edwin\work\autocopy\TO_LOCATION1"
Set "TOLOCATION2Folder=d:\edwin\work\autocopy\TO_LOCATION2"

:: copy files TOLOCATION1Folder
For /F "Delims=" %%! in ('Dir "%sourceDir%\%isoissue%.i*" /b /s /a-d 2^>nul') do (@echo.%%! &(@xcopy "%%!" "%TOLOCATION1Folder%\" /i /y /h /f /c))

:: copy files TOLOCATION2Folder
For /F "Delims=" %%! in ('Dir "%sourceDir%\%isoissue%.i*" /b /s /a-d 2^>nul') do (@echo.%%! &(@xcopy "%%!" "%TOLOCATION2Folder%\" /i /y /h /f /c))


:done
title,Done.......

echo.&pause>nul

goto :eof

hopeless but trying


0

Response Number 2
Name: Judago
Date: October 5, 2008 at 00:12:36 Pacific
Reply:

Sorry, What I posted had a little mistake in it. Try changing:

This


for /f %%g in (d:\edwin\work\autocopy\list.txt) do call :body %%G

to this:

for /f %%g in (d:\edwin\work\autocopy\list.txt) do call :body %%g

I accidentally mixed the case up on the for loop variable, %%g was set but %%G wasn't.


0

Response Number 3
Name: einstein8
Date: October 6, 2008 at 07:35:12 Pacific
Reply:

Hi Judago thanks for replying. Its working perfectly now.. i just edited the last part of that script and removed the echo.&pause at the end and it worked like a charm.. you rock!!!

hopeless but trying


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: Variable from A List File Part 2

Variable from a list file www.computing.net/answers/programming/variable-from-a-list-file/17057.html

Creating a variable from a txt file www.computing.net/answers/programming/creating-a-variable-from-a-txt-file/16486.html

Setting variables from a txt file www.computing.net/answers/programming/setting-variables-from-a-txt-file/15639.html