masdf123
asked on
Copy every new file to a folder automatically
Hi Guys,
How can I "cut" all new files from folder A and paste them to folder b and c automatically?
Maybe every 1 min or so?
Thanks
How can I "cut" all new files from folder A and paste them to folder b and c automatically?
Maybe every 1 min or so?
Thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
sorry the correct command is xcopy on windows not cp
As an added note to Qlemo's comment, you can use the following robocopy switch to check for updates and do any additional copies "every 1 min or so":
/MOT:m :: MOnitor source; run again in m minutes Time, if changed.
Robocopy has a lot of powerful options. Use robocopy /? to list them all. For example, you might want to copy file ownership information in addition to the file contents.
/MOT:m :: MOnitor source; run again in m minutes Time, if changed.
Robocopy has a lot of powerful options. Use robocopy /? to list them all. For example, you might want to copy file ownership information in addition to the file contents.
xcopy - as I told, but with /D, please. Without it will copy *all* existing files, no matter if changed or not.
SyncToy can do that task, but it is oversized for this particular case, and runs too long to call it every frew minutes.
SyncToy can do that task, but it is oversized for this particular case, and runs too long to call it every frew minutes.
Really good point, apresence. RoboCopy can monitor itself for changes, no need for a scheduled task then.
ASKER
do I need to install xcopy? how does it keep running?
masdf123, xcopy (and robocopy) are included with Server 2008. They are command-line tools, so you have to start a command prompt to use them.
I really think robocopy is the better option. If you run xcopy every minute it'll have to check the entire folder for changes each time. I suspect you'll see your disk usage very high all the time.
Robocopy "monitors" the file system for changes only (Windows sends it a message to notify when something's changed... until then it waits idly), so it's not producing any disk activity unless something is changed.
I really think robocopy is the better option. If you run xcopy every minute it'll have to check the entire folder for changes each time. I suspect you'll see your disk usage very high all the time.
Robocopy "monitors" the file system for changes only (Windows sends it a message to notify when something's changed... until then it waits idly), so it's not producing any disk activity unless something is changed.
This time you are wrong. apresence. /MON does no more than check for changes using the modify time stamp of files. There is not much difference between issuing xcopy every x minutes and using RoboCopy /MON:x.
And as I have seen here on EE, /MON does *not* apply to subfolders, only to the "root" folder you provide. If you have to monitor subfolders, there needs to run a RoboCopy /MON for each subfolder.
Regarding performance and cpu load introduced - if you scan folders every minute, you can assume that is kept in cache all the time, so it should not be stressing that much.
And as I have seen here on EE, /MON does *not* apply to subfolders, only to the "root" folder you provide. If you have to monitor subfolders, there needs to run a RoboCopy /MON for each subfolder.
Regarding performance and cpu load introduced - if you scan folders every minute, you can assume that is kept in cache all the time, so it should not be stressing that much.
ASKER
When I run this, do I leave the command prompt open? Does it run like a schedule or so?
Can I send the files to 2 different directory's as destination?
Can I send the files to 2 different directory's as destination?
When you run RoboCopy, and it is finished, the DOS window is no longer required.
You can't send the files to 2 different locations. To do that, you need to run another xcopy or robocopy.
You can't send the files to 2 different locations. To do that, you need to run another xcopy or robocopy.
ASKER
When I use /mon:1.
Will it do the job?
Will it do the job?
As said, it will only apply to the root folder, and only for one destination. If you run two, one for each destination, and do not need to monitor subfolders, then /mon:1 will do.
ASKER
Does this run as a process? How do I cancel it?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
So I leave the command prompt open?
And if I logoff, it would close the dos prompt?
And if I logoff, it would close the dos prompt?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Masff123, you should use the robocopy command Qelmo gave you with the monitor option.
However it looks liek you want this batch file/ command to run silently reguardless of peopel logging on or off the computer.
To accomplish this you should make the batch file/command a scheduled task running as an administrator on the computer; and schedule it to start every day at midnight, and set it to kill itself if still running at 11:59 PM so you don't miss any 1 minute iterations. Obviously it woudl be best to have the task running on a server or other stable environment.
However it looks liek you want this batch file/ command to run silently reguardless of peopel logging on or off the computer.
To accomplish this you should make the batch file/command a scheduled task running as an administrator on the computer; and schedule it to start every day at midnight, and set it to kill itself if still running at 11:59 PM so you don't miss any 1 minute iterations. Obviously it woudl be best to have the task running on a server or other stable environment.
ASKER
Solved
this program will sync folders for you and get pretty granular for a free tool. It also can be scheduled through windows scheduler.