Solved

How to copy files and get a resultant text file ?

Posted on 2007-04-09
7
196 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
7 Comments
 
LVL 83

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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup". After a while, you have entered a loop for Auto repair which does not fix anything and you will be in a  panic as all your work w…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

707 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

14 Experts available now in Live!

Get 1:1 Help Now