Script failing on name

I have a hazel rule which invokes the following Applescript:
The AppleScript above runs a python script which works apart from when the file name has a "(" in the name. Is there a way that I can get around this issue?
- Code: Select all
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
on hazelProcessFile(theFile)
set getDate to ((path to scripts folder as text) & "xxx:getDatePython.scpt")
set dateVar to run script alias getDate with parameters {theFile}
set TID to AppleScript's text item delimiters
set AppleScript's text item delimiters to " "
try
set pyYY to word 1 of dateVar
set pyMM to word 2 of dateVar
set pyDD to word 3 of dateVar
set pyValue to word 4 of dateVar
set pyName to (words 5 thru -1 of dateVar) as text
end try
set AppleScript's text item delimiters to TID
return {hazelExportTokens:{exportName:pyName as string, yyear:pyYY as string, mmonth:pyMM as string, dday:pyDD as string, vvalue:pyValue as string}}
end hazelProcessFile
The AppleScript above runs a python script which works apart from when the file name has a "(" in the name. Is there a way that I can get around this issue?