Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

complex "copy" and "move" scenario possible? 1

Status
Not open for further replies.

benzguy777

Vendor
Sep 17, 2002
74
0
0
Scenario:

Folder A = attach folder/PDF files regularly come in
Folder B = no security/ users can edit/modify files
Folder C = READ only folder

PDF files reguarly (every few minutes) come in FOLDER A as attachments. My attachments are very important. What I want to happen is COPY the contents of "A" to "B" and after copying MOVE only/exactly the copied files from "A" to "C".

The program/software must know that only the FILES COPIED are MOVED.

This has to be done every 2-3 minutes as new attachments are coming in again.

Any suggestions?

 
Why dont you make a batch file to do so, and use it as a schedule task? A+, MCP, CCNA
marbinpr@hotmail.com

Keep fighting for your knowledge!

 
Yeah, like konquito said, it sounds like you could do it in a batch file with 2 simple commands:

COPY %1\*.* %2
MOVE %1\*.* %3

...where %1 is the path to Folder A, %2 is the path to Folder B, and %3 is the path to Folder C. Then just setup a scheulde task for the batch file.
 
yes - but how will the MOVE command know what EXACLTY it copied to "B".

*.* will copy and move all the files. This cannot happen.

If I use *.* to copy from A>B and use *.* to copy from A>C after, what if a couple of new files are downloaded to A? Then B will not have these files anymore (which cannot happen).

 
If attachments are coming in so that quickly that there is the possibility of new files appearing in A between the COPY/MOVE process, then you should DEFINITELY not do it with those two commands. :)
 
Okay, I think I might have something for ya.

Copy this into a batch file in the root of the C drive. Call it batch.bat (or anything, for that matter).

@echo off
dir /b C:\A > c:\filelist.txt
for /F "eol=; delims=," %%a in (filelist.txt) do @process.bat %%a

Copy this into a batch file in the same place called process.bat

@echo off
copy C:\A\%1 C:\B
move C:\A\%1 C:\C

Before you use these, make sure you change "C:\A", "C:\B", and "C:\C" to the appropriate folders.

When batch runs, it creates a file in the root of C called "filelist.txt". This is a listing of all files in the attachments folder. Then it proceeds to read that file line by line, doing what's in the process.bat file (copy & move) for each file listed in filelist.txt.

The only files that will ever be moved or copied are the ones that exist when batch initially runs (the ones that end up in filelist.txt), so if files show up AFTER batch has already started, they are unaffected. They just sit there until next time the batch runs.

If there are no files in the attachment folder when batch runs, filelist.txt is conveniently empty, and nothing happens.

YOU MIGHT WANT TO DO SOME TESTING WITH THIS BEFORE USING IT. :)
 
Man this is GREAT! I think we have a very good solution! Will work in this ASAP!!!

Will let you know results!

Thanks a million disord3r!

There sure are great people here.



 
I happen to loose some files always on the MOVE "C" folder. The COPY "B" folder always seems to have more files than the MOVE "C". About 5-20 files sometimes. Everytime I execute the batch I have about 150-280 files on Folder A.

Any ideas? Will a delay command between COPY and MOVE help?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top