set theOrgGoogleMapUrl to "https://maps.google.com/maps?q=%E6%9D%B1%E4%BA%AC%E3%82%BF%E3%83%AF%E3%83%BC&hl=en&ie=UTF8&ll=35.658595,139.745439" as text
display dialog "GoogleMapのURLをペーストしてください" default answer the theOrgGoogleMapUrl with icon 1 with title "GoogleMapのURLをペーストしてください" default button 1
copy the result as list to {the theOrgGoogleMapUrl, BottPressNo}
set theAwkComLL to "echo " & quoted form of theOrgGoogleMapUrl & "| awk -F \"ll=\" '{print($2)}' |awk -F \"&\" '{print($1)}' " as text
set theAwkComQ to "echo " & quoted form of theOrgGoogleMapUrl & "| awk -F \"q=\" '{print($2)}' |awk -F \"&\" '{print($1)}' " as text
try
set theGoogleLlNo to do shell script theAwkComLL as text
if theGoogleLlNo is "" then
display alert "GPSデータを取得出来ませんでした"
end if
on error
set theGoogleLlNo to do shell script theAwkComQ as text
if theGoogleLlNo is "" then
display alert "GPSデータを取得出来ませんでした"
end if
end try
set AppleScript's text item delimiters to {","}
set theGoogleLlNoList to every text item of theGoogleLlNo as list
set theLatitude to item 1 of theGoogleLlNoList as text
set theIntegerLatitude to theLatitude div 1 as text
set theLatitude to (text 2 thru 8 of (((theLatitude mod 1) as string) & "000000") as string)
set theLatitude to theIntegerLatitude & theLatitude
set theDecimalLatitudeA to (((theLatitude as number) - (theIntegerLatitude as number)) as number) * 60
set theIntegerDecimalLatitudeA to theDecimalLatitudeA div 1 as text
set theDecimalLatitudeB to (((theDecimalLatitudeA as number) - (theIntegerDecimalLatitudeA as number)) as number) * 100 as integer
set theLatitude to theIntegerLatitude & "," & theIntegerDecimalLatitudeA & "." & theDecimalLatitudeB & "N" as text
set theLongitude to item 2 of theGoogleLlNoList as text
set theIntegerLongitude to theLongitude div 1 as text
set theLongitude to (text 2 thru 8 of (((theLongitude mod 1) as string) & "000000") as string)
set theLongitude to theIntegerLongitude & theLongitude
set theDecimalLongitudeA to (((theLongitude as number) - (theIntegerLongitude as number)) as number) * 60
set theIntegerDecimalLongitudeA to theDecimalLongitudeA div 1 as text
set theDecimalLongitudeB to (((theDecimalLongitudeA as number) - (theIntegerDecimalLongitudeA as number)) as number) * 100 as integer
set theLongitude to theIntegerLongitude & "," & theIntegerDecimalLongitudeA & "." & theDecimalLongitudeB & "E" as text
set tneAns to theLatitude & "\n" & theLongitude
display dialog "Bridge用のGPSの値です" default answer the tneAns with icon 1 with title "Adobe Bridge 用GPS値" default button 1 buttons {"XMPファイルも作る", " 終了 "}
if button returned of the result is "XMPファイルも作る" then
do shell script "date > /tmp/ApplicationChk.xmp"
set theTmpXmpFile to (the path to startup disk as string) & "tmp:ApplicationChk.xmp" as alias
set theFileInfo to default application of (info for theTmpXmpFile) as text
if (theFileInfo contains "Bridge") is false then
display alert "XMPファイルがAdobe Bridgeに関連づけられていません"
else if (theFileInfo contains "Bridge") is true then
set theSaveXmpPath to (the path to application support from user domain as text) & "Adobe:XMP:Metadata Templates:"
set theGoogleLlNoQ to do shell script theAwkComQ as text
if theGoogleLlNoQ is "" then
set theDateTime to (do shell script "date +'%Y%m%d_%H%M%S'" as string)
set theXmpFileName to (theLatitude & "_" & theLongitude & "_" & theDateTime & ".xmp") as text
set theXmpFileName to my replace(theXmpFileName, ",", ".") as text
set theGooogleMapQ to theLatitude & " " & theLongitude
else
set theGooogleMapQ to my decodeURL(theGoogleLlNoQ)
set theXmpFileName to (theGooogleMapQ & ".xmp") as text
end if
set theDistPathXmpFile to (POSIX path of ((theSaveXmpPath & theXmpFileName) as text)) as text
do shell script "touch " & quoted form of theDistPathXmpFile
set theDistFileXmpFile to (POSIX file theDistPathXmpFile) as alias
set theXMPline to "<?xpacket begin=\"\" id=\"W5M0MpCehiHzreSzNTczkc9d\"?>"
do shell script "echo " & quoted form of theXMPline & " > " & quoted form of theDistPathXmpFile
set theXMPline to "<x:xmpmeta xmlns:x=\"adobe:ns:meta/\" x:xmptk=\"Adobe XMP Core 5.3-c011 66.145661, 2012/02/06-14:56:27\">"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to "<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to "<rdf:Description rdf:about=\"\""
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " xmlns:dc=\"http://purl.org/dc/elements/1.1/\""
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " xmlns:photoshop=\"http://ns.adobe.com/photoshop/1.0/\""
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " xmlns:Iptc4xmpCore=\"http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/\""
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " xmlns:Iptc4xmpExt=\"http://iptc.org/std/Iptc4xmpExt/2008-02-29/\""
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " xmlns:exif=\"http://ns.adobe.com/exif/1.0/\""
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " photoshop:Instructions=\"" & theGooogleMapQ & "\""
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " Iptc4xmpCore:Location=\"" & theGooogleMapQ & "\""
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " exif:GPSLatitude=\"" & theLatitude & "\""
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " exif:GPSProcessingMethod=\"MANUAL\""
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " exif:GPSAltitude=\"0.00 m\""
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " exif:GPSLongitude=\"" & theLongitude & "\">"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " <dc:subject>"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " <rdf:Bag>"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " <rdf:li>" & theGooogleMapQ & "</rdf:li>"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " </rdf:Bag>"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " </dc:subject>"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " <Iptc4xmpExt:LocationShown>"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " <rdf:Bag>"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " <rdf:li"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " Iptc4xmpExt:Sublocation=\"" & theGooogleMapQ & "\"/>"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " </rdf:Bag>"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " </Iptc4xmpExt:LocationShown>"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " </rdf:Description>"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " </rdf:RDF>"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to "</x:xmpmeta>"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to "<?xpacket end=\"w\"?>"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
tell application "Finder"
set label index of alias (((theSaveXmpPath & theXmpFileName))) to 5
open folder theSaveXmpPath
activate
end tell
end if
else if button returned of the result is "終了" then
end if
to replace(theText, orgStr, newStr)
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to orgStr
set tmpList to every text item of theText
set AppleScript's text item delimiters to newStr
set tmpStr to tmpList as text
set AppleScript's text item delimiters to oldDelim
return tmpStr
end replace
on decodeURL(str)
set scpt to "php -r 'echo urldecode(\"" & str & "\");'"
return do shell script scpt
end decodeURL