Subject: | |
From: | |
Reply To: | |
Date: | Mon, 13 Feb 2012 10:23:33 +0900 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
Hello Mark,
Thank you very much for all your help!
I ended up with the following script:
-----
property script_fname : "DocComp.sh" -- your "external script" name -- by Kino, 2006-05-20
property file_1 : ""
property runtime : 0
property firsttime : "yes"
property firstfile_passed : "no"
property secondfile_passed : "no"
property filetypes : {".txt", ".html", ".rtf", ".rtfd", ".doc", ".docx", ".wordml", ".odt", ".webarchive", ".xml"}
on idle
if runtime < (current date) - 5 * minutes then
set file_1 to ""
quit
end if
return 1
end idle
on open (droppedItemsList)
set my_path to POSIX path of (path to me)
set shell_scpt to quoted form of (my_path & "Contents/Resources/" & script_fname)
set runtime to current date
if (number of droppedItemsList) ≥ 3 then
display dialog "This droplet accepts two files."
return quit
else if (number of droppedItemsList) = 1 then
if firsttime = "yes" then
display dialog "Please drop another file..."
set firsttime to "no"
end if
if file_1 = "" then
set file_1 to first item of (droppedItemsList)
set file_1 to POSIX path of file_1
return
else
set file_2 to first item of (droppedItemsList)
set file_2 to POSIX path of file_2
end if
else if (number of droppedItemsList) = 2 then
set file_1 to first item of (droppedItemsList)
set file_1 to POSIX path of file_1
set file_2 to second item of (droppedItemsList)
set file_2 to POSIX path of file_2
end if
if file_1 = file_2 then
display dialog "You have chosen the same file. Quitting..."
return quit
end if
repeat with i in filetypes
if file_1 ends with i then
set firstfile_passed to "yes"
end if
if file_2 ends with i then
set secondfile_passed to "yes"
end if
end repeat
set thename_1 to do shell script "basename " & quoted form of file_1
set thename_2 to do shell script "basename " & quoted form of file_2
if firstfile_passed = "no" then
display dialog "The first file \"" & thename_1 & "\" is not of the supported types. Quitting..."
return quit
end if
if secondfile_passed = "no" then
display dialog "The second file \"" & thename_2 & "\" is not of the supported types. Quitting..."
return quit
end if
display dialog "Comparing " & return & thename_1 & return & "with " & return & thename_2
try
do shell script "/bin/sh " & shell_scpt & space & quoted form of file_1 & space & quoted form of file_2
--set res to the result
on error errMsg
display dialog "An error occurred: " & errMsg
end try
set file_1 to ""
set file_2 to ""
set firsttime to "yes"
set firstfile_passed to "no"
set secondfile_passed to "no"
quit
end open
-------
The "DocComp.sh" compares two files (of different types) with Unix diff, and displays the result in a nice (readable) rtf file with TextEdit. I will upload the result in my web site, when my friend, Kino, will give me the permission.
Thank you very much again!
Best regard,
Nobumi Iyanaga
Tokyo,
Japan
|
|
|