Skip to content

Instantly share code, notes, and snippets.

@rummelonp
Created October 31, 2010 07:02
Show Gist options
  • Save rummelonp/656234 to your computer and use it in GitHub Desktop.
Save rummelonp/656234 to your computer and use it in GitHub Desktop.
LinuxでDropboxの特定のフォルダ以下のファイルを同期完了後に移動するスクリプト
#!/usr/bin/python
import os, shutil, glob, commands
dropbox_dir = os.path.expanduser('~/dropbox')
airvideo_dir = '/var/airvideo'
dropbox_script_path = dropbox_dir + "/bin/dropbox"
monitering_dirs = {
dropbox_dir + "/movie" : airvideo_dir + "/movie",
dropbox_dir + "/music" : airvideo_dir + "/music",
dropbox_dir + "/photo" : airvideo_dir + "/photo"
}
for from_dir in monitering_dirs :
to_dir = monitering_dirs[from_dir]
for filename in glob.glob(from_dir + '/*') :
result = commands.getoutput(dropbox_script_path + " filestatus " + filename)
if result.endswith('up to date') :
shutil.move(filename, to_dir)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment