Solved

How to copy files and get a resultant text file ?

Posted on 2007-04-09
7
231 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
Industry Leaders: 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

Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
NTP Servers 4 44
Office 365 skype for buiseness on a windows 10 machine 3 26
How to change fonts in windows live mail 3 18
powershell event viewer 1 20
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
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). …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

756 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