Copy Every File Added to a Folder to Another Folder


Recommended Posts

I just implemented an instance of Mayan EDMS as a document manager. It's a destructive file manager. Everything added to the import folders are renamed to a unique identifier, file extension is stripped, it's copied to the app storage folder, and the original file in the import folder is deleted. 

 

Is there a way I can get every file added to the import folder immediately copied to a backup folder? I'd like it to happen as soon as it's added.   

Link to comment

Not exactly the same, but I used a find command that checks a folder and it copies from A to B and moves to C. 

find /mnt/cache/uploads/incoming/* -iname "*.mkv" -type f -mmin +10 -exec cp {} /mnt/cache/uploads/2check/ \; -exec mv {} /mnt/cache/uploads/Tv-Incoming/ \;
 

So it checks Incoming folder and copies to 2check then moves incoming to Tv-incoming

 

So this kinda does what your asking, but not exactly.  You could look for some code that utilizes inotifywait

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.