- on synchronize by keyFilePath
- set savedDelimiters to AppleScript's text item delimiters
- set AppleScript's text item delimiters to return
- set thePaths to text items of (do shell script "fname=\"$(basename " & quoted form of keyFilePath & ")\";export LANG=ja_JP.UTF-8; mdfind 'kMDItemDisplayName == \"'\"$fname\"'\"' | while read path; do [ -f \"$path\" ] && [ -r \"$path\" ] && [ -w \"$path\" ] && ls -lT \"$path\"; done | awk 'NF<10{next} { date=sprintf( \"%s%02s%02d%s\", $9, $6, $7, $8 ); for(i=1; i<10 ; i++) $i=\"\";sub(\"^ *\",\"\");print date, $0}' | sort -r | cut -d ' ' -f 2-")
- set AppleScript's text item delimiters to savedDelimiters
- if not ((count of thePaths) > 1) then return
- set sourcePath to first item of thePaths
- set destinationPaths to choose from list items 2 thru -1 of thePaths OK button name "Copy" with title "Update the same name files" with prompt "Copy “" & sourcePath & "” to:" with multiple selections allowed
- if (count of destinationPaths) is 0 then return
- try
- set AppleScript's text item delimiters to ASCII character 10 -- 10 was LF
- set quotedDestinationPaths to quoted form of (destinationPaths as text)
- set AppleScript's text item delimiters to savedDelimiters
- set theResult to do shell script "echo " & quotedDestinationPaths & "| while read path; do cp " & quoted form of sourcePath & " \"$path\"; done"
- on error message
- display dialog message
- end try
- end synchronize
- on open droppedItems
- if (count of droppedItems) is 0 then return
- synchronize by POSIX path of item 1 of droppedItems
- end open
- -- for example
- synchronize by "hoge.txt"
- synchronize by "../../Hoge/Desktop/hoge.txt"
- synchronize by "/Users/Hoge/Desktop/hoge.txt"
Sample