Skip to content

Instantly share code, notes, and snippets.

@amatsuda
Created January 29, 2012 11:20
Show Gist options
  • Save amatsuda/1698341 to your computer and use it in GitHub Desktop.
Save amatsuda/1698341 to your computer and use it in GitHub Desktop.
キャッシュでローカルディスクが溢れないようにちょっとずつBitcasaにコピるスクリプト
SRC_DIR = '/Users/a_matsuda/Music/iTunes/iTunes Media/Music'
TARGET_DIR = '/Users/a_matsuda/Bitcasa/backup/Music/iTunes/iTunes Media/Music'
def cache_is_empty?
s = `du -s ~/Library/Caches/com.bitcasa.Bitcasa/Data/bks/outgoing | awk '{print $1}'`
s.to_i.zero?
end
def already_copied?(artist)
File.exists? "#{TARGET_DIR}/#{artist}"
end
Dir.glob("#{SRC_DIR}/*").each do |artist_dir|
next if already_copied?(artist_dir.sub "#{SRC_DIR}/", '')
sleep(30) && puts('waiting...') until cache_is_empty?
puts "copying #{artist_dir}..."
`cp -R "#{artist_dir}" "#{TARGET_DIR}"`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment