2

I'm writing a script to move files out of a certain folder in my Dropbox when they are done syncing.

For example, I want to have a folder called "TrashBackup" that as soon as I put stuff in there,(after is done syncing) my server picks it up and moves it out of Dropbox into another place in the filesystem (ultimately deleting it from my laptop).

I was using pyinotify but the problem is that I don't know how to know when it is done syncing. I might end up moving before a possibly really big file isn't done transferring.

I was thinking of setting a timer to see when was the last time that files changed, and if its more than 20 minutes then go ahead and move it out of Dropbox.. But it seems like a hackaround. Also if I was transfering 1GB files I might be pushing my luck depending on Dropbox's speed and my local bandwith utilization.

Maybe I should start monitoring the .dropbox.cache folder? Any ideas?

1
  • How about using the dropbox API?
    – Acorn
    Apr 8, 2012 at 19:10

2 Answers 2

2

Why not try using the Dropbox CLI? There are several methods in there that should prove useful to you.

For achieving your specific goal, I can think of two commands that would be useful: dropbox status, and dropbox filestatus. The former will return "Idle" when syncing is complete. The latter returns the sync status of one or more files.

2
  • I think it will work, thanks! (I will check if its idle after an event is done and if it is I will move the files) I will wait to see if there are any other ways first
    – Andre
    Apr 8, 2012 at 19:40
  • Great! I would consider creating a new method within dropbox.py based off of the filestatus method. That way, you can cover all possible cases (e.g. the directory does not exist, or Dropbox is not running). Then, you could "trash backup" something by calling python dropbox.py trashbackup <dir>. Let me know how it goes!
    – David Cain
    Apr 8, 2012 at 19:57
0

You could use the API, (specifically, /metadata: https://www.dropbox.com/developers/reference/api#metadata ) to poll that folder occasionally, (e.g. every 5-10 min) to see if anything new is there, and if so, perform the move as desired. The advantage of the API in this case is that the file will only show once it is done syncing anyway. (Monitoring .dropbox.cache is not recommended.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.