Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to copy files and get a resultant text file ?

Posted on 2007-04-09
7
Medium Priority
?
247 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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 1500 total points
ID: 18887508
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
Windows Server 2003 introduced persistent Volume Shadow Copies and made 2003 a must-do upgrade.  Since then, it's been a must-implement feature for all servers doing any kind of file sharing.
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…

670 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