Exifæ å ±ãåé¤ãããµã¼ãã¹ã¡ãã¥ã¼ã«ãã
前回の日記ã§ãç»åã®exifæ å ±ãæä½ããexiftoolã³ãã³ããè¦ãããããã«ãã¦ãexiftoolã³ãã³ãã¯ããªãå¤æ©è½ã§ããªãã·ã§ã³ã®è¨å®æ¬¡ç¬¬ã§ç¸å½é«åº¦ãªæ©è½ãå¼ãåºããããã¾ã å ¨ç¶ä½¿ãããªãã¦ã¯ããªãããå°ããã¤ä½¿ãæ¹ãåãã£ã¦ãããããããGUIæä½ãåºæ¬ã®èªåã«ã¨ã£ã¦ããã£ããè¦ãããªãã·ã§ã³æå®ããããå¿ãã¦ãã¾ããã...ããã¶ããæ¯åãªãã·ã§ã³ã調ã¹ç´ãã¦ä½¿ãç¾½ç®ã«ãªãããããªããªãããã«ããã使ããããªæ©è½ã«çµãè¾¼ãã§ããµã¼ãã¹ã¡ãã¥ã¼ã«ç»é²ãã¦ãããã¨ã«ããã
exiftoolã³ãã³ãã®ä½¿ãæ¹ãæ¢ã
ãµã¼ãã¹ã¡ãã¥ã¼ã«ç»é²ããåã«ãããå°ã便å©ã«ä½¿ããããªãªãã·ã§ã³æå®ã調ã¹ã¦ã¿ãã
- ãã¹ã¦ã®Exifæ
å ±ãåé¤ããã
- å ãã¡ã¤ã«~/Desktop/IMG_0439.JPGã¯ã~/Desktop/IMG_0439.JPG_originalã«åæå¤æ´ãã¦ããã¯ã¢ããããã
- Exifæ å ±ãåé¤ãããã¡ã¤ã«ã¯ã~/Desktop/IMG_0439.JPGã¨ãã¦ä¿åãããã
$ exiftool -all= ~/Desktop/IMG_0439.JPG
$ exiftool -geotag= ~/Desktop/IMG_0439.JPG
- å ãã¡ã¤ã«ãããã¯ã¢ããããä¸æ¸ãããå ´åã¯ã-overwrite_originalãªãã·ã§ã³ã追è¨ããã
$ exiftool -all= -overwrite_original ~/Desktop/IMG_0439.JPG
- åºåãããã¡ã¤ã«åãæå®ãããå ´åã¯ã-oãªãã·ã§ã³ã追è¨ããã
- -oãªãã·ã§ã³ã®å¼æ°ã«æå®ããæååããã¡ã¤ã«åã«ãªãã
- -oãªãã·ã§ã³ã®å¼æ°ã«ãã©ã¼ãããæååãæå®ããã°ãå
ãã¡ã¤ã«åãã«ã¼ã«ã«å¾ã£ã¦å¤æ´ã§ããã
- %d...å ãã¡ã¤ã«ã¾ã§ã®ãã£ã¬ã¯ããªãåºåããã
- %f...å ãã¡ã¤ã«ã®ååï¼æ¡å¼µåãªãï¼ãåºåããã
- %e...å ãã¡ã¤ã«ã®æ¡å¼µåï¼.ãå«ã¾ãªãï¼ãåºåããã
- %c...ãã¡ã¤ã«åãéè¤ãã¦ããå ´åãéè¤ããªããªãã¾ã§1ã2ã3...ã¨ã«ã¦ã³ãã¢ããããæ°åãåºåããã
$ exiftool -all= -o %dno_exif%+c_%f.%e ~/Desktop/IMG_0439.JPG
- ä¸è¨ã§~/Desktop/no_exif_IMG_0439.JPGããããã¯éè¤ããã°~/Desktop/no_exif_1_IMG_0439.JPGã«åºåãããã
- æ°åã®é¨åã¯å¿ è¦ã«å¿ãã¦2ã3...ã¨ãéè¤ããªããã¡ã¤ã«åã«ãªãã¾ã§å¤åããã
- ã¡ãªã¿ã«ã%cã®ããªã¨ã¼ã·ã§ã³ã¯ããªãè±å¯ã
-o A%-cZ.txt # AZ.txt, A-1Z.txt, A-2Z.txt ... -o B%5c.txt # B.txt, B00001.txt, B00002.txt ... -o C%.c.txt # C0.txt, C1.txt, C2.txt ... -o D%-.c.txt # D-0.txt, D-1.txt, D-2.txt ... -o E%-.4c.txt # E-0000.txt, E-0001.txt, E-0002.txt ... -o F%-.4nc.txt # F-0001.txt, F-0002.txt, F-0003.txt ... -o G%+c.txt # G.txt, G_1.txt G_2.txt ... -o H%-lc.txt # H.txt, H-b.txt, H-c.txt ...
ãã®è¨å®ã§è¯ããããªæ°ãããããä¸ã¤åé¡ãçºçã
- ãã¹ã¦ã®Exifæ å ±ãåé¤ãã¦ãã¾ãã¨ãç»åã®æ¹åãç¡è¦ããã¦ãå¤ãªåãã®ç»åã«ãªã£ã¦ãã¾ãå ´åãããã®ã ã
- ç»åã®æ¹åã ãã¯ä¿æãããã以ä¸ã®ããã«ãã¦ã¿ãã
n=`/usr/bin/exiftool -b -orientation ~/Desktop/IMG_0439.JPG` /usr/bin/exiftool -all= -orientation#=$n -o %dno_exif%+c_%f.%e ~/Desktop/IMG_0439.JPG
AppleScriptã«ã¾ã¨ãã
ä¸è¨ã³ã¼ããAppleScriptããå¼ã³åºãããã«ãã¦ã確èªãã¤ã¢ãã°ãå®äºã¡ãã»ã¼ã¸ã¨çµã¿åããã¦ä»¥ä¸ã®ããã«ãã¦ã¿ãã
on run {input, parameters} set msg to (input's number as text) & "件ã®ãã¡ã¤ã«ããããã¹ã¦ã®Exifæ å ±ãåé¤ãã¾ãã"
activate
display dialog msg buttons {"ãã£ã³ã»ã«", "ä¸æ¸ã", "å¥åã§ä¿å"} default button "ãã£ã³ã»ã«" with icon 2
set button_pressed to result's button returned
set pathList to {} repeat with aFile in input
set aUNIXPath to (aFile as text)'s POSIX path
--do shell script "/usr/bin/exiftool -all= " & aUNIXPath
--å ãã¡ã¤ã«å.æ¡å¼µå_originalã«ããã¯ã¢ããããã
if button_pressed is "ä¸æ¸ã" then
--ä¸æ¸ãä¿åãã
do shell script "n=`/usr/bin/exiftool -b -orientation " & aUNIXPath & "`; /usr/bin/exiftool -all= -orientation#=$n -overwrite_original " & aUNIXPath
set pathList's end to aUNIXPath & return
else
--no_geotag_ã«ã¦ã³ãæ°_å ãã¡ã¤ã«å.æ¡å¼µåã§ä¿åãã
do shell script "n=`/usr/bin/exiftool -b -orientation " & aUNIXPath & "`; /usr/bin/exiftool -all= -orientation#=$n -o %dno_exif%+c_%f.%e " & aUNIXPath
set pathList's end to "no_exif#_" & my fileName(aUNIXPath) & return
end if
end repeat
do shell script "/usr/local/bin/growlnotify 'ãã¹ã¦ã®Exifæ å ±ãåé¤ãã¾ããã' -m " & pathList as text
return input
end run
on fileName(unixPath) tell application "Finder"
(POSIX file unixPath as alias)'s name
end tell
end fileName
Automatorã«çµã¿è¾¼ãã§ãµã¼ãã¹ã«ãã
- ã¯ã¼ã¯ããã¼ã®ãã³ãã¬ã¼ãã«ãµã¼ãã¹ãé¸æã
- "ãµã¼ãã¹"ã¯æ¬¡ã®é¸æé ç®ãåãåãã¾ãï¼ã¤ã¡ã¼ã¸ãã¡ã¤ã«
- æ¤ç´¢å¯¾è±¡ï¼Finder.app
- Automatorã®ä¿åãå®äºããã¨ããµã¼ãã¹ã¡ãã¥ã¼ã«è¿½å ãããï¼
ã·ã§ã«ã¹ã¯ãªããç
- å®ã¯ãAutomatorã«ã¯ã·ã§ã«ã¹ã¯ãªãããçµã¿è¾¼ããã
- ãã¤ã¢ãã°ã表示ãããããå¿ è¦æ§ããªããã°ã以ä¸ã®ãããªã·ã§ã«ã¹ã¯ãªãããããã®ã¾ã¾ãµã¼ãã¹ã«ãªãã®ã ã
- AppleScriptãã·ã§ã«ã¹ã¯ãªããã§æ¸ãç´ãã¦ã¿ããï¼æåã®ç¢ºèªãã¤ã¢ãã°ã¯çç¥ããï¼
name_text="" for fpath in "$@" do n=`/usr/bin/exiftool -b -orientation "$fpath"` /usr/bin/exiftool -all= -orientation#=$n -o %dno_exif%+c_%f.%e "$fpath" # fname="${fpath##*/}" /* ãã¡ã¤ã«å */ # fname_no_ext="${fname%.*}" /* ãã¡ã¤ã«åï¼æ¡å¼µåãªãï¼ */ # fdir="${fpath%/*}" /* ãã£ã¬ã¯ã㪠*/ # fext="${fpath##*.}" /* æ¡å¼µåï¼.ãå«ã¾ãªãï¼ */ fname="${fpath##*/}" name_text="${name_text}no_exif_#_${fname}\n" done echo -e "$name_text"|/usr/local/bin/growlnotify "ãã¹ã¦ã®Exifæ å ±ãåé¤ãã¾ããã"
- å¼æ°ã¯$@ã§åå¾ã§ãããï¼å
¥åã®å¼ã渡ãæ¹æ³ï¼å¼æ°ã¨ã㦠ãé¸æããå ´åï¼
- OSXã¯ãã¡ã¤ã«åã«åè§ã¹ãã¼ã¹ãå¤ç¨ãããã®ã§ãã¯ã©ã¼ãã§å²ãã§"$@"ã¨ããã
- é¸æã¢ã¤ãã ã®ãã¹ããããã¹ãã§åå¾ã§ããã
- ãªã¼ãã¡ã¼ã¿ã¼ã«çµã¿è¾¼ãã¨ã以ä¸ã®ããã«ãªã£ãã
- åèãã¼ã¸ï¼ç´ æ´ããããã¼ã¸ã«æè¬ã§ãï¼ï¼
以ä¸ã§ããã¹ã¦ã®Exifæ
å ±ãåé¤ããï¼ä½ãç»åã®æ¹åã ãã¯æ®ãï¼ãµã¼ãã¹ã¡ãã¥ã¼ã®åºæ¥ä¸ããã
追è¨
- ãã¹ãããã¡ã¤ã«åã¨ãã£ã¬ã¯ããªãåé¢ããã«ã¯ãbasenameã»dirnameã³ãã³ãã便å©ã ã£ãã
$ basename /a/b/c.txt c.txt $ basename /a/b/c.txt .txt c $ dirname /a/b/c.txt /a/b