Hi,
Thanks to KniazidisR, I’ve been able to write a nifty little script to batch-manage a bunch of EyeTV files before delivering them to Handbrake for encoding.
Being your run-of-the-mill eager-beaver, I’ve added to the process the treatment via a Python script of the .txt files extracted from the EyeTV package. Everything works fine except when the name of the text file contains a single quote when all hell breaks loose --the do shell script pass the name of the file as an argument, so… yeah.
After looking right and left, I’ve found what I call the “on searchReplace” method to deal with this problem but I can"t seems to make it work, even for just one file as follows :
on searchReplace(thisText, searchTerm, replacement)
set AppleScript's text item delimiters to searchTerm
set thisText to thisText's text items
set AppleScript's text item delimiters to replacement
set thisText to "" & thisText
set AppleScript's text item delimiters to ""
return thisText
end searchReplace
tell application "Finder"
set search_T to "'"
set rep to "\\'" -- 2 "\" because only one throws an error
set selected to selection as alias
set textName to selected as text
set res to searchReplace(textName, search_T, rep)
end tell
Whenever I try to run this, I’ve got an Finder error on the searchReplace(textName, search_T, rep) part of he last line with code number -1708.
Bonus question, is there a way to tell AppleScript to not stop on an error in a repeat when something goes wrong, to just get to the next item of the list and keep going on the loop ?