Changes from the previous script are basically three.
On the first line put the path to the python, for example #!/usr/bin/python
Check if there are any selected files using NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
And finally show a message when the script is finished.
Here's the script:
#!/usr/bin/python import os from PIL import Image import shutil x = None try: x = os.environ['NAUTILUS_SCRIPT_SELECTED_FILE_PATHS'] x = x.split('\n') except: pass if len(x)>1: files = [f.split(os.path.sep)[-1:][0] for f in x if f.endswith('.JPG') or f.endswith('.jpg')] else: files = [f for f in os.listdir('.') if f.endswith('.JPG') or f.endswith('.jpg')] cdate_tag = 0x9003 for f in files: if os.path.isfile(f): img = Image.open(f) date = img._getexif()[0x9003].split(' ')[0].replace(':','_') if not os.path.isdir(date): os.mkdir(date) shutil.move(f,os.path.join(date,f)) img.fp.close() import gtk dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_CLOSE, "Done!") dialog.run() dialog.destroy()
No comments:
Post a Comment