Last active
July 31, 2024 21:54
-
-
Save loshlee/1fa59a5efbf1db770fbb61f1e6034769 to your computer and use it in GitHub Desktop.
This is the source for an AppleScript droplet that you can create yourself on a Mac using Script Editor to save the script as an application. (The rest of this description is included in a comment at the beginning of the script source.)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
This is the source for an AppleScript droplet that you can create yourself on a Mac using Script Editor to save the script as an application. It will use Terminal to return basic media info for a file that you drop onto its icon. Media-info must be installed on your Mac System, of course. It can be installed using Homebrew. This targets media-info as installed by Homebrew on a Silicon Mac system. You may find it necessary to change "/opt/homebrew/bin/mediainfo" to "/usr/local/bin/mediainfo" if you use it on an Intel Mac where Homebrew was used to install media-info. Important: Remember, to make the resulting document function as an AppleScript Droplet app, you must save the script as an Application using Script Editor. | |
*) | |
property temppath : "/private/tmp/" | |
property startnum : 0 | |
property newline : ASCII character 10 | |
property tmpfile : "/tmp/execme.command" | |
on open the_items | |
my mediaInfo(the_items) | |
end open | |
on mediaInfo(the_items) | |
set theshellscript to "" | |
repeat with the_item in the_items | |
set the_item to the_item as alias | |
tell application "Finder" | |
set sost to (container of the_item) as string | |
end tell | |
set pos_filepath to POSIX path of sost | |
set this_filepath to (the_item as string) | |
set thesourcename to (name of (info for the_item)) | |
set namepart to (name extension of (info for the_item)) | |
set the_source_file to POSIX path of this_filepath | |
--set the clipboard to quoted form of the_source_file | |
set theshellscript to the theshellscript & "/opt/homebrew/bin/mediainfo" & space & (quoted form of the_source_file) & space & "; echo '" & " | |
========================== | |
Media Information for" & space & "\"" & thesourcename & "\"" & " | |
========================== | |
';" | |
end repeat | |
##set the clipboard to theshellscript | |
set theshellscript to theshellscript & "sleep 3;mv" & space & (quoted form of tmpfile) & space & (quoted form of (POSIX path of (path to trash))) | |
do shell script "echo " & quoted form of theshellscript & " > " & tmpfile | |
repeat | |
do shell script "chmod +x " & tmpfile | |
do shell script "open -a Terminal.app" & space & tmpfile | |
exit repeat | |
end repeat | |
end mediaInfo | |
on run | |
set the_items to ((choose file) as list) | |
mediaInfo(the_items) | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment