Skip to content

Instantly share code, notes, and snippets.

@samuelspiza
Created March 28, 2010 15:38
Show Gist options
  • Save samuelspiza/346810 to your computer and use it in GitHub Desktop.
Save samuelspiza/346810 to your computer and use it in GitHub Desktop.
Check if all files downloaded with Amazon MP3-Downloader are backuped.
@ECHO off
SET /P destination=compare to folder in:
python %USERPROFILE%\bin\check-mp3-backup.py -d%destination%
#!/usr/bin/env python
"""Check if all files downloaded with Amazon MP3-Downloader are backuped."""
import sys
import os
import optparse
LOCAL_DIR = "d:/mp3downloads"
IGNORE = ["Folder.jpg", "AlbumArtSmall.jpg"]
def main(argv):
options = getOptions(argv)
sourceFiles = getSourceFiles()
missingFiles = []
for file in sourceFiles:
# replace "d:/" with options.dest
file = os.path.join(options.dest, file[3:])
if os.path.basename(file) not in IGNORE and \
not os.path.exists(file):
missingFiles.append(os.path.basename(file))
print "%s missing files." % len(missingFiles)
for file in missingFiles:
print file
return 0
def getOptions(argv):
parser = optparse.OptionParser()
parser.add_option("-d", "--dest",
dest="dest", default="h:", metavar="PATH",
help="compare the local 'mp3downloads' directory with "
"the one in PATH")
return parser.parse_args(argv)[0]
def getSourceFiles():
sourceFiles = []
for root, dirs, files in os.walk(LOCAL_DIR):
sourceFiles.extend([os.path.join(root, f) for f in files])
return sourceFiles
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment