You will need to edit the properties at the beginning of this script to be appropriate for your own file names (pFilenamePrefix and pFilenameExtension will both need to be changed plus pNumDigits in your file name). I have given this script the barest of testing.
if pNumDigits is equal to 5 then your filenames will look like:
scene-00001.targa
if pNumDigits is equal to 4 then your filenames will look like:
scene-0001.targa
I hope this helps.
Kevin
property pFrameRate : 24
property pFrameDuration : 600 div pFrameRate
property pMovieCompressor : "Sorenson Video 3 Compressor"
property pNumberOfSlates : 8
property pFilenamePrefix : "scene-" -- "DSCN"
property pFilenameExtension : ".targa" -- ".JPG"
property pSlateFont : "Verdana"
property pSlateFontSize : 24 -- overridden in code further down 1/16 of the height of the frames.
property pSlateBackColor : {0, 0, 0} -- black
property pSlateTextColor : {65535, 65535, 65535} -- white {red, green, blue}
property pNumDigits : 5
property pShowFrames : true -- false is faster but you cant see the progress of the frames being processed.
on run
set topFolder to choose folder with prompt "Choose folder containing folders of movie frames: "
set folderList to list folder topFolder without invisibles
set myList to {}
repeat with j from 1 to the number of items in folderList
if the first character of (item j in folderList) is not "." then
set tempItem to (topFolder as string) & (item j in folderList) as alias
if folder of (info for tempItem) is true then
set end of myList to tempItem
end if
end if
end repeat
repeat with theFolder in myList
ProcessFolder(theFolder)
end repeat
end run
on CreateGraphicDocument(theWidth, theHeight)
tell application "iMagine Photo"
if pShowFrames is true then
return make new window document with properties {dimensions:{theWidth, theHeight}}
else
return make new graphic document with properties {dimensions:{theWidth, theHeight}}
end if
end tell
end CreateGraphicDocument
on ProcessFolder(theFolder)
-- first up determine dimensions of targa files.
--find the dimensions of the first image file and assume all others are the same.
set theInfo to (info for theFolder)
set folderName to name of theInfo
set folderPath to theFolder as string
set firstFile to missing value
set filePathName to missing value
try
set filePathName to folderPath & pFilenamePrefix & my add_leading_zeros(1, pNumDigits - 1) & pFilenameExtension
set firstFile to filePathName as alias
on error
display dialog "File doesn't exist: " & filePathName
return
end try
tell application "iMagine Photo"
set thisImporter to import graphic firstFile
if the component error of thisImporter is not equal to 0 then
close thisImporter
display dialog "Error importing initial frame file: " & filePathName
return
end if
set {x, y, theWidth, theHeight} to the natural bounds of thisImporter
close thisImporter
set pSlateFontSize to theHeight div 16
set thisDocument to my CreateGraphicDocument(theWidth, theHeight)
set movieEditor to make new movie editor with properties {dimensions:{theWidth, theHeight}}
set the data compressor of movieEditor to pMovieCompressor
set the export compression quality of movieEditor to high
tell thisDocument to create composition element with properties {class:filled rectangle, color:pSlateBackColor, bounds rectangle:{0, 0, theWidth, theHeight}}
tell thisDocument to create composition element with properties {class:standard text, font:pSlateFont, font size:pSlateFontSize, start from:centre, start point:{theWidth div 2, theHeight div 2}, color:pSlateTextColor, background color:pSlateBackColor, drawing text:folderName}
set export folder location of movieEditor to theFolder
set export file name of movieEditor to (folderName & ".mov")
set editing of movieEditor to true
repeat with i from 1 to pNumberOfSlates
tell movieEditor to append sample with properties {source document:thisDocument, sample duration:pFrameDuration, source rectangle:{0, 0, theWidth, theHeight}}
end repeat
set maxPossFrames to (10 ^ pNumDigits) - 1
set theFile to missing value
repeat with i from 1 to maxPossFrames
set filePathName to folderPath & pFilenamePrefix & my add_leading_zeros(i, pNumDigits - 1) & pFilenameExtension
try
set theFile to filePathName as alias
my ProcessFile(theFile, thisDocument)
tell movieEditor to append sample with properties {source document:thisDocument, sample duration:pFrameDuration, source rectangle:{0, 0, theWidth, theHeight}}
on error
exit repeat
end try
end repeat
set editing of movieEditor to false
export movieEditor
close movieEditor
close thisDocument
end tell
end ProcessFolder
on ProcessFile(theFile, theDocument)
tell application "iMagine Photo"
set thisImporter to import graphic theFile
if the component error of thisImporter is not equal to 0 then
close thisImporter
display dialog "Error importing frame file: " & name of (info for theFile)
return
end if
set the drawing destination of thisImporter to theDocument
draw thisImporter
close thisImporter
end tell
end ProcessFile
--For example, if the maximum number of leading zeros is set to 2, then the
--results will range from 001 to 999. If the maximum number of leading zeros
--is 3, then the results will range from 0001 to 9999, and so on.
on add_leading_zeros(this_number, max_leading_zeros)
set the threshold_number to (10 ^ max_leading_zeros) as integer
if this_number is less than the threshold_number then
set the leading_zeros to ""
set the digit_count to the length of ((this_number div 1) as string)
set the character_count to (max_leading_zeros + 1) - digit_count
repeat character_count times
set the leading_zeros to (the leading_zeros & "0") as string
end repeat
return (leading_zeros & (this_number as text)) as string
else
return this_number as text
end if
end add_leading_zeros