Solved

How to copy files and get a resultant text file ?

Posted on 2007-04-09
7
235 Views
Last Modified: 2010-04-20
I have a notebook that is connected to a Windows 2000 Server.
I need to copy files on a daily basis from the Server to the notebook.
I need a script that runs on all the files that i need to copy and inform me (errors.txt or something similar) of the files not copied... for any reason.. (file is in use...etc...)
0
Comment
Question by:ammounpierre
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 84

Expert Comment

by:oBdA
ID: 18880728
Safest way is to do this with robocopy.exe from the Resource Kit Tools.
robocopy "E:\Some\Folder" "C:\Some\Other\Folder" *.* /e /log:"C:\Temp\errors.txt"
Check robocopy.doc in the installation folder for details about the command line arguments, it's a very useful and powerful tool.

Windows Server 2003 Resource Kit Tools
http://www.microsoft.com/downloads/details.aspx?FamilyID=9D467A69-57FF-4AE7-96EE-B18C4790CFFD&displaylang=en
0
 
LVL 4

Expert Comment

by:Soutie
ID: 18880869
another way is to use the DOS copy command (or xcopy) but using a ">' flag to capture the output to a text file.

eg copy c:\*.* c:\temp > c:\log.txt

you will need to use the /y option though because all outputs get piped into the text file.... even prompts to overwrite
0
 
LVL 4

Expert Comment

by:Soutie
ID: 18880877
Sorry correction

eg. copy c:\*.xls c:\temp\*.xls /y > c:\xls.txt
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:ammounpierre
ID: 18881580
But I need actions to be taken when the copying fails on certain files... like retrying only those files after few minutes or so...
both the copy and robocopy do not allow for this...

thanks
0
 
LVL 30

Expert Comment

by:SteveGTR
ID: 18881843
After doing the copy you can check ERRORLEVEL for an errors:

REM ** xcopy or robocopy command
if ERRORLEVEL 1 echo Error

You could create a routine to process files

@echo off

setlocal

del retrybatch.bat 2>NUL

for /f "tokens=*" %%a in ('dir /b /a-d c:\*.* 2^>NUL') do call :COPYFILE "%%a"

if exist retrybatch.bat echo Some files not copied, run retrybatch.bat to try again

goto :EOF

:COPYFILE

if /i "%~1"=="retrybatch.bat" goto :EOF

copy "%~1" c:\temp
if ERRORLEVEL 1 echo (copy "%~1" c:\temp)>>retrybatch.bat

Good Luck,
Steve
0
 
LVL 38

Expert Comment

by:Shift-3
ID: 18882129
Robocopy can retry after a specified interval.  Use the /R switch to specify the number of times to retry and the /W flag to specify the number of seconds to wait.
0
 
LVL 10

Accepted Solution

by:
Phadke_hemant earned 500 total points
ID: 18887508
0

Featured Post

Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

Question has a verified solution.

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

Suggested Solutions

Issue: One Windows 2008 R2 64bit server on the network unable to connect to a buffalo Device (Linkstation) with firmware version 1.56. There are a total of four servers on the network this being one of them. Troubleshooting Steps: Connect via h…
Configuring Remote Assistance for use with SCCM
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 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

739 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