Capturing the file from Copy Command

Microsoft Windows server 2003 enterprise
December 31, 2009 at 04:27:43
Specs: Win Server 2003, intel
Hi ,
I am generating a copy command file based on the files available in my source folder and
using the copy file generated i am creating the extensions to the file.But the files in my source folder will be updated by a batch due to which some of the files will be renamed.

Below is one of my copy command, I will have 70,000 lines in my actual copy command file.

COPY C:\FolderA\001587985 C:\FolderB\001587985.pdf

After the file is genrated I am executing this and while executing if the actual file got renamed i will get an error "The system cannot find the file specified."

so What I want to do is if I get the above error I want to genarate a log.txt with the file name.


C:\FolderA\0534124585 C:\FolderB\0534124585.doc

The system cannot find the file specified

I want to capture the 0534124585 file name in a serparete logfile.txt.

How can I write a btach script for this.


See More: Capturing the file from Copy Command

Report •

December 31, 2009 at 12:06:51
if you need to keep the copy operation on one line (copy-commandfile being generated by output of "dir /b" etc.)
you will need to join 3 operations and make one line:
set xx=C:\FolderA\001587985 & copy !xx! !xx!.pdf>nul & if errorlevel 1 echo.!xx!>>logfile

(you will need to insert as first line of copycommand script:)
setlocal enabledelayedexpansion

Report •

January 1, 2010 at 04:34:23
Sunitha, are you sure this folder is not being "changed", in the mean time. I mean; you are listing out the files, in order to create a batchfile that will change the files, then run it ... but during the whole of this process, is something changing anything inside this directory (other than what you are running) ?

Otherwise, just do a DIR first, then do all of your changes, example:

DIR C:\FolderA\* >> C:\debug.log

Report •
Related Solutions

Ask Question