Computing.Net > Forums > Programming > Writing to a file from Xcopy

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

Writing to a file from Xcopy

Reply to Message Icon

Original Message
Name: eggonlegs
Date: August 5, 2005 at 05:25:27 Pacific
Subject: Writing to a file from Xcopy
OS: Win XP Pro
CPU/Ram: 3500+ AMD 64 / 2gig
Comment:

Hi guys,
I'm trying to copy some files from one location to another and then write the screen output to a file (the file will be used later on). Currently I have this:

xcopy [souce path]\*.* [destination path] /Y >c:\batch\outcome.txt

This works but if a file is in use it doesn't say that it couldn't copy that file, I have tried adding error levels into the command but then it only writes the errors out. Ideally I'd like it to write out a file something like this:

C:\batch\test\01.txt
C:\batch\test\02.bmp - Source file in Use
C:\batch\test\test.txt
C:\batch\test\testxcop.bat


The format doesn't have to be exact of course as long as you can tell which files haven't copied, any help would be much appreciated.


Report Offensive Message For Removal


Response Number 1
Name: Mechanix2Go
Date: August 6, 2005 at 07:52:00 Pacific
Reply: (edit)

I think you're out of luck with xcopy, much as I like it.

This bat uses COPY and makes an error log.

If you're as bad a typist as I am, you may want to add some error checking.

::=== copyerr.bat
@echo off > error.log

if %2'==' goto :syntax

:main
set source=%1
set dest=%2
cd %source%
type nul > error.log
for /f %%F in ('dir/b/a-d') do call :copier %%F
goto :eof

:copier
copy %1 %dest% > nul
if errorlevel 1 echo %1 NO GO >> error.log
goto :eof

:syntax
echo syntax: %0 sourceDIR destinationDIR

:eof
::===

M2


If at first you don't succeed, you're about average.


Report Offensive Follow Up For Removal

Response Number 2
Name: eggonlegs
Date: August 7, 2005 at 23:28:01 Pacific
Reply: (edit)

Ahh right, thanks very much for that :D


Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home








Do you have your own blog?

Yes
No
I did before
I will soon


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge
Poll History




Data Recovery Software