Good news! Image Events can convert TGA to JPG.
So I wrote the following script with Script Editor, but since this is an Automator forum I wrapped up the code for use with Automator's
Run AppleScript action. This provides more flexibility to integrate the script in a larger workflow, and has more saving options (such as Finder plug-in).
The script accepts the results of any actions that return a list of file references and/or aliases. For example, Finder's
Get Selected Finder Items or
Get Folder Contents. (This step may be omitted if the workflow is saved as a Finder plug-in. In this case Finder will automatically send the current selection to the first action of the workflow.)
The script then creates a new dated folder inside the folder that contains your source images. The source images are copied to the new folder and renamed. Finally Image Events opens each copied file and converts it to JPEG format.
To use the script, drag Automator's
Run AppleScript action into your workflow and replace the default code from the body of the action with the following:
click here to
open this script in your editor
<pre style="font-family: 'Monaco', 'Courier New', Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:400px">on run {input, parameters}
set {output, folder_exists} to {{}, false}
tell application "Finder" to repeat with a_file in input
-- 1. Get the original file location and name.
set {source_folder, source_name} to {container, name} of a_file
-- 2. Replace .TGA with .JPG in the file name variable.
tell (a reference to AppleScript's text item delimiters)
set {tid, contents} to {contents, ".tga"}
set {final_name, contents} to {source_name's text items, ".jpg"}
set {final_name, contents} to {final_name as text, tid}
end tell
-- 3. Create a new folder inside the original folder.
if not folder_exists then
tell (current date) to set time_stamp to "TGA->JPG " & short date string & space & it's hours & "." & it's minutes & "." & it's seconds
set final_folder to make new folder at source_folder with properties {name:time_stamp}
set folder_exists to true
end if
-- 4. Copy the original file to the new folder, replacing the original file name with the new file name.
set final_file to duplicate a_file to final_folder
set name of final_file to final_name
set final_file to ((final_folder as alias) as Unicode text) & final_name
-- 5. Open the copied file and convert it to JPG.
tell application "Image Events"
set doc to open file final_file as alias
save doc as JPEG
close doc
end tell
-- 6. Pass the new file locations on to the next action (if any).
set end of output to (final_file as alias)
end repeat
return output
end run</pre>
PowerMac G5 (June 2004) 2x1.8GHz 1.25GB, PowerBook G4 (12-inch DVI) 1x1GHz 768MB Mac OS X (10.4.5)