Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 56 lines (42 sloc) 1.437 kb
931eade @jfinken Initial commit of scripts to the python sandbox.
authored
1 #!/usr/bin/env python
2 # encoding: utf-8
3 """
4 untitled.py
5
6 Created by josh with great help from bryan on 2009-07-10.
7 Copyright (c) 2009 earthmine, inc. All rights reserved.
8 """
9
10 import sys
11 import os
12 import subprocess
13
14 # grab the path from the command line, where the path is the last
15 # element in the command line list
16 dir = sys.argv[-1]
17 command = 'find ' + dir + ' -name "*.jpg"'
18 #print "About to call: %s" % (command)
19
20 # execute the find command
21 output = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE).communicate()[0]
22
23 # split the list by whitespace
24 files = output.split()
25 # files = files[:10] #only operate on 10 files
26
27 # call 'identify' for each jpg and grep for a corruption
28 status = []
29 files_examined = 0
30
31 for file in files:
32 #identify = 'identify -regard-warnings ' + file
33 #out = subprocess.Popen(identify, shell=True, stdout=subprocess.PIPE).communicate()[0]
34
35 # this guy gives me the return code... 0 is good, 1 is bad
36 out = subprocess.call(["identify", "-regard-warnings", file])
37
38 if out == 1:
39 status.append(file)
40
41 files_examined = files_examined + 1
42
43 # results
44 print ""
45 print "-----------------------------------------"
46 print "Files examined:\t",files_examined
47
48 if len(status) == 0:
49 print "All jpegs are intact!"
50 else:
51 print "Corrupt jpegs:\t",len(status),"\nThey are:"
52 for jpg in status:
53 print jpg
54
55 print "-----------------------------------------"
Something went wrong with that request. Please try again.