Created
July 10, 2014 17:06
-
-
Save Achifaifa/f3644fb2de9dda14e3a8 to your computer and use it in GitHub Desktop.
Small script for product photography sessions with hundreds of files. Take photo, note the number (DSC_XXXX.nef), and add the product name and the weight (Requirements for this particular assignment). run [python this_file.py reference_file], and all the photos will be renamed to product_(weight kg).nef. Fiddling a lite with the code allows to w…
This file contains 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
#! /usr/bin/env python | |
import os, sys | |
if __name__=="__main__": | |
try: os.chdir(os.path.dirname(__file__)) | |
except OSError: pass | |
filepath="./"+sys.argv[1] | |
with open (filepath,"r") as listfile: | |
for line in listfile: | |
for filename in os.listdir("./"): | |
if filename=="DSC_"+line.partition(',')[0]+".nef": | |
targetname=line.partition(',')[2].partition(',')[0]+"_("+line.strip().partition(',')[2].partition(',')[2]+"kg).nef" | |
print filename,targetname | |
os.rename(filename,targetname) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment