Solved

Dos For loop

Posted on 2008-06-10
2
1,115 Views
Last Modified: 2008-07-31
Hi Experts,

I am trying to copy a list of zip files from a shared drive to my drive.
The problem is that the zip files differ slightly (time stamped) and I can only pull one down

\\128.xx.xxx.xxx\c$\calypso\calypso\Calculator8806_OFFLINE_60008.log_034004_2008_6_10.zip
\\128.xx.xxx.xxx\c$\calypso\calypso\Calculator8806_OFFLINE_60008.log_052629_2008_6_10.zip
\\128.xx.xxx.xxx\c$\calypso\calypso\Calculator8806_OFFLINE_60008.log_070133_2008_6_10.zip
\\128.xx.xxx.xxx\c$\calypso\calypso\Calculator8806_OFFLINE_60008.log_084614_2008_6_10.zip
\\128.xx.xxx.xxx\c$\calypso\calypso\Calculator8806_OFFLINE_60008.log_095722_2008_6_10.zip
\\128.xx.xxx.xxx\c$\calypso\calypso\Calculator8806_OFFLINE_60008.log_112157_2008_6_10.zip
\\128.xx.xxx.xxx\c$\calypso\calypso\Calculator8806_OFFLINE_60008.log_113838_2008_6_10.zip
    1 file(s) copied.

I guess what I need to do is give each copy a counter value but Im having problems doing this.

Can you please help.

Thanks,
Margin_Walker
REM 09/02/2007

REM This script will grab the CALCULATOR logs from each blade on each server listed in OFFLINE_Servers.txt
 
 

FOR /F "skip=1 tokens=1 usebackq" %%i in (OFFLINE_Servers.txt) do  copy \\%%i\c$\calypso\calypso\Calculator8806_OFFLINE_60008.log_*2008_6_10.zip \\clypcalb10l\d$\pb_utility\rafter\%%i_RAF%Count%TER_Calculator8806_OFFLINE_60008.zip 
 

IF NOT %ERRORVALUE%==0 GOTO ERRORHANDLE
 

GOTO TERMINATE

:ERRORHANDLE

ECHO Error ! %ERRORVALUE%

pause
 

:TERMINATE

Open in new window

0
Comment
Question by:Margin_Walker
2 Comments
 
LVL 3

Accepted Solution

by:
gs121 earned 75 total points
ID: 21753981
Why not xcopy

xcopy \\128.xx.xxx.xxx\c$\calypso\calypso\Calculator8806_OFFLINE_60008.* c:\logs\128.x.x.x\data......
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 21946699
There are several choices.

1 - Copy everything using gs121's suggestion.
2 - Copy the latest one.
3 - Copy all but rename them with a counter.

Which door will you choose? Remember, you can only choose one door!!!

(Now hop around like an over excited member to the public on some cheesy game show!).
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
When you upgrade from Windows 8 to 8.1 or to Windows 10 or if you are like me you are on the Insider Program you may find yourself with many 450MB recovery partitions.  With a traditional disk that may not be a problem but with relatively smaller SS…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now