Created
January 29, 2012 11:20
-
-
Save amatsuda/1698341 to your computer and use it in GitHub Desktop.
キャッシュでローカルディスクが溢れないようにちょっとずつBitcasaにコピるスクリプト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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