Solved

How to copy files and get a resultant text file ?

Posted on 2007-04-09
7
239 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 85

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
Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

 

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

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

635 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