Simple applescript
Need a simple AppleScript to run a audio file over a jpeg picture. I am running mac osx high sierra.
iMac 21.5″, macOS 10.13
Need a simple AppleScript to run a audio file over a jpeg picture. I am running mac osx high sierra.
iMac 21.5″, macOS 10.13
The following AppleScript will set a JPG image on a audio file, and in this example, that audio file is an .mp3.
or, a transparent PNG over an M4A audio file.
Copy and paste the following code into the Script Editor, click compile, and run.
-- setIcon.applescript
-- Choose a file to have the new icon set on
-- Choose an image (ideally an .icns) to replace file or folder original icon
use framework "Cocoa"
use AppleScript version "2.4" -- Yosemite or later
use scripting additions
property isImage : {"public.image", "com.apple.icns"}
property adesktop : (path to desktop as text) as alias
property apictures : (path to pictures folder as text) as alias
property imgFormat : {"public.image", "com.apple.icns"}
property NSImage : a reference to current application's NSImage
property NSWorkspace : a reference to current application's NSWorkspace
-- select the audio file first
set fObject to POSIX path of (choose file default location adesktop without invisibles, multiple selections allowed and showing package contents)
-- then the image
set theImg to POSIX path of (choose file of type imgFormat default location apictures without invisibles, multiple selections allowed and showing package contents)
if my setIcon(fObject, theImg) = true then
display dialog "The object icon has been set… wait for Finder to refresh the icon."
else
display dialog "The object icon was not set for some reason."
end if
return
Tested: macOS Ventura 13.6.3
The following AppleScript will set a JPG image on a audio file, and in this example, that audio file is an .mp3.
or, a transparent PNG over an M4A audio file.
Copy and paste the following code into the Script Editor, click compile, and run.
-- setIcon.applescript
-- Choose a file to have the new icon set on
-- Choose an image (ideally an .icns) to replace file or folder original icon
use framework "Cocoa"
use AppleScript version "2.4" -- Yosemite or later
use scripting additions
property isImage : {"public.image", "com.apple.icns"}
property adesktop : (path to desktop as text) as alias
property apictures : (path to pictures folder as text) as alias
property imgFormat : {"public.image", "com.apple.icns"}
property NSImage : a reference to current application's NSImage
property NSWorkspace : a reference to current application's NSWorkspace
-- select the audio file first
set fObject to POSIX path of (choose file default location adesktop without invisibles, multiple selections allowed and showing package contents)
-- then the image
set theImg to POSIX path of (choose file of type imgFormat default location apictures without invisibles, multiple selections allowed and showing package contents)
if my setIcon(fObject, theImg) = true then
display dialog "The object icon has been set… wait for Finder to refresh the icon."
else
display dialog "The object icon was not set for some reason."
end if
return
Tested: macOS Ventura 13.6.3
Thanks to
User level:
Level 10
125,922 points
May 4, 2007 4:59 PM in response to hypergenesb
QuickTime Pro is the answer:
Open the "video" (JPEG), select all and copy.
Switch to the audio file, select all and choose "Add to Selection & Scale".
Save As (self-contained) to make a QuickTime file that shows the image and plays the audio.
QuickTime Player is AppleScript aware and combining files can be done.
How to create QuickTime movie from JPEG a… - Apple Community
Simple applescript