[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details

File Copy and re-name file question.

Asked by GordonMasson in Microsoft Excel Spreadsheet Software

I am writing a bit of code and I need a sub that will execute a file move for me and if there is a duplicate I want to move it to a different folder and rename it.

The process will be used over and over so it is possible that a file that has previously been processed will be processed for a second time. This is what I want to trap.

Lets say that the start folder is C:\RawFiles
And the end folder is C:\ProcessedFiles
And the error folder is C:\ErrorFiles

Under normal circumstances I want to move files from C:\RawFiles to C:\ProcessedFiles but if the file name already exists in C:\ProcessedFiles then I want to move it to the C:\ ErrorFile folder

Lets say the file is TestMessage.msg

NO DUPLICATE FILES
1.Check if a file called TestMessage.msg exists in the folder C:\ProcessedFiles
If not then Move C:\RawFiles\TestMessage.msg to C:\ProcessedFiles\TestMessage.msg

DUPLICATE FILES
2. If a file called TestMessage.msg exists in the folder C:\ProcessedFiles
Then make a copy of the file thats already been processed in C:\ProcessedFiles in the folder C:\ErrorFiles but rename it DF0-TestMessage.msg
i.e. the file will become C:\ErrorFiles\ DF0-TestMessage.msg    DF0 = Duplicate File 0

3. If a file called C:\ErrorFiles\DF0-TestMessage.msg already exists the folder C:\ ErrorFiles then do not make a copy of the file in the C:\ErrorFiles folder

4. Move the file C:\RawFiles\TestMessage.msg to C:\ErrorFiles but rename it C:\ErrorFiles\DF1-TestMessage.msg

5. On the off chance that we already have a C:\ErrorFiles\DF1-TestMessage.msg file in the C:\ErrorFiles folder then rename the file C:\ErrorFiles\DF2-TestMessage.msg or C:\ErrorFiles\DF3-TestMessage.msg and so on.

Thanks for your help
 
Related Solutions
Keywords: File Copy and re-name file question.
 
Loading Advertisement...
 
[+][-]09/09/09 05:52 AM, ID: 25290622Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 - Hierarchy / EE_QW_3_20080625