Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Copy Source | Copy HTML #!/usr/bin/env python # -*- coding: UTF-8 -*- """ sorts images by resolution""" import os,sys from PIL import Image # dirname = os .path.abspath( sys .argv[ 1 ]) try : newdir = os .path.abspath( sys .argv[ 2 ]) except : newdir = dirname def image_sort (dirname, newdir, recur= 0 ): if not recur: print 'sorting started ...' # else : print 'sorting started in %s...' %dirname # # imagelist = [] if os .path.isdir(dirname): for x in os .listdir(dirname): absx = dirname+ os .sep+x if os .path.isfile(absx):imagelist.append(absx) else : #print 'summon subsort in %s'%x image_sort (absx, newdir+ os .sep+x,recur= 1 ) # / for name in imagelist: try : resolution = Image. open (name).size # except IOError: print 'seems not image: ' + name, '/n' continue imdir = '%sx%s' %(resolution[ 0 ],resolution[ 1 ]) imdir = os .path.join(newdir,imdir) # if os .path.split(dirname)[- 1 ] == os .path.split(imdir)[- 1 ]: continue elif not os .path.exists(imdir): #print 'making dir %s'%imdir os .mkdir(imdir) try : os .system( 'move "%s" "%s"' %(name,imdir)) except WindowsError: print 'error with ' + name, '/n' if not recur: print 'sorting completed!' if __name__ == '__main__' : image_sort (dirname, newdir)
Source: https://habr.com/ru/post/85306/
All Articles