I am working on at script that takes the file i have selected,
exports it in quicktime with H.264 resolution 720x405, at 70% quality
The script should also remove the last 4 characters in the filepath string,
so i can add a “_h264.mov” til the file name.
My current script looks like this:
tell application "Path Finder"
set selection_list to selection
repeat with one_item in selection_list -- one_item is a fsItem (fsFile or fsFolder)
set theResultPosix to POSIX path of one_item -- gets a posix path
set theResult to (POSIX file theResultPosix) as string
set theFileName to (theResultPosix & "_h264.mov")
end repeat
end tell
tell application "QuickTime Player"
open theResultPosix
export front document to theFileName as QuickTime movie using most recent settings with replacing
quit
end tell
Can anyone help with removing the last 4 digits of my file string, and also with QT export setting?
set theResultPosix to "/some/path/to/some/file.abc"
set theFileName to (text 1 through -5 of theResultPosix & "_h264.mov")
theFileName --> "/some/path/to/some/file_h264.mov"
But, if you are actually trying to strip off an existing extension (that might not be exactly three characters long):
set theResultPosix to "/some/path/to/some/file.abcdefg"
set theFileName to (trimExtension from theResultPosix) & "_h264.mov"
theFileName --> "/some/path/to/some/file_h264.mov"
to trimExtension from nameString
local otid
set otid to text item delimiters
try
set text item delimiters to {"."}
if (count text items of nameString) is greater than 1 then
set nameString to text 1 through text item -2 of nameString
end if
set text item delimiters to otid
on error m number n from o partial result r to t
set text item delimiters to otid
error m number n from o partial result r to t
end try
nameString
end trimExtension