help writing windows script for os x

Started by iwhisperer, November 25, 2011, 11:58:03 AM

Previous topic - Next topic

iwhisperer

Hi,
My coworker wrote several .bat files for windows to tag rather large batches of images and I need to transfer these to terminal on the Mac.  I made several attempts but results are not coming out the same including a new csv file is placed ~/ vs. the directory I have in the script; ~/Documents/Tag/

Help "translating" the .bat's to the same result on the Mac would be very much appreciated.

.bat's:
1. exiftool.exe -k -csv -caption-abstract -headline -keywords -imagedescription "C:\Documents and Settings\" > out1.csv

Exports meta and overwrites current out1.csv file in same folder as exiftool.exe
I edit the out1.csv with new values, save and close, then the run the next .bat

2. exiftool.exe -k -overwrite_original -csv=out1.csv "C:\Documents and Settings\"
Images get renamed per the three tags in 1.

3. exiftool.exe -k "-FileName<${Keywords}.%%e" "C:\Documents and Settings\"
Not even sure what this one does since I only use the first two but would be nice to know.

Again, thanks for the help!

Phil Harvey

#1
The commands could be:

1. exiftool -csv -caption-abstract -headline -keywords -imagedescription ~/Documents/Tag > ~/out1.csv

2. exiftool -overwrite_original -csv=/Users/$USER/out1.csv ~/Documents/Tag

3. exiftool '-FileName<${Keywords}.%%e' ~/Documents/Tag

The only tricky one is 2.  You can't use "~" in the -csv= argument because the shell doesn't expand it unless it is at the start of the argument.

To make a "batch" file on OS X, put the command in a text file, then run "chmod 755 FILE" to make it executable.  This saves typing the whole command each time.

- Phil

Edit: To make the batch file clickable in OS X, either name it with a ".command" extension, or select "File/Get Info" from the Finder menu and set "Open with" to the Terminal app.
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

iwhisperer

Thanks Phil! I'll give it a shot and report back.

iwhisperer

One tweak to 1 seems to work, and 2 works a treat. FWIW we use these tags in picasa and volusion.

1. exiftool -k -csv -caption-abstract -headline -keywords -imagedescription ~/Documents/Tag > out1.csv

out1.csv created in ~/ listing source file path

Did not use 3 since 2 met my needs. Also, I went ahead and made Automator apps after getting an admin error using .command plus, hey, it's an app ;)

Thanks again!