[b]Hi All,
I am new to apple script i just trying to create script which will check the given style sheet is available or not in the seleted file.
Can anybody help me on this as soon as possible.
The below script i have wrote but it find only if the full style sheet name matchs but i want any of the word either first or last names.[/b]
tell application "Finder"
choose file of type {"XPRJ"} with prompt "Choose the Quark File"
set theFiles to result
open file theFiles
tell document 1 of application "QuarkXPress"
set stylshts to {"2c entry subttl", "2c entry ttl"}
repeat with ThisText in stylshts
set ThisText to ThisText as string
if (exists style spec ThisText) then
display dialog ("You're using the stylesheet" & return & ThisText)
else
display dialog ("All Style Sheets are New HTML Standard")
end if
end repeat
end tell
end tell
You’ll need to get all style sheet names, and check each one separately to find partial matches.
tell document 1 of application "QuarkXPress"
--for example, to check to see if the first and last words "custom" and "2"
--exist in any style sheet in document 1
set styleNamesToCheck to {"custom", "2"}
--get all style sheet names
set allStyleSheets to name of every style spec
-->{"Normal","custom style sheet name 1","custom style sheet name 2" }
--check for 'contains' or 'begins with' or 'ends with' as needed
repeat with aName in allStyleSheets
repeat with aWord in styleNamesToCheck
if aName contains aWord then ¬
display dialog "Style \"" & aName & "\" contains \"" & aWord & "\""
end repeat
end repeat
repeat with aName in allStyleSheets
repeat with aWord in styleNamesToCheck
if aName begins with aWord then ¬
display dialog "Style \"" & aName & "\" begins with \"" & aWord & "\""
end repeat
end repeat
repeat with aName in allStyleSheets
repeat with aWord in styleNamesToCheck
if aName ends with aWord then ¬
display dialog "Style \"" & aName & "\" ends with \"" & aWord & "\""
end repeat
end repeat
end tell
Hi all,
The following script will do the selected quark will be duplicate and add _1 at the end of the file and check the style sheets naming in the document after showed the pop-up the duplicate file will be trashed. But i got the Error message “Can’t get file “xxxx” of application Finder” if only when i choose the file from either Work folder or Server. But it works fine if i choose the file from the Desktop.
tell application "Finder"
choose file of type {"XPRJ"} with prompt "Choose the Quark file you want to check"
set f to result
tell application "Finder"
set {name:fName, name extension:fExtn, folder:fFldr} to f
set baseName to fName's text 1 thru -((count fExtn) + 2) & "_"
set n to 1
set newName to baseName & n & "." & fExtn
considering case
tell (get name of fFldr's files) to repeat while newName is in it
set n to n + 1
set newName to baseName & n & "." & fExtn
end repeat
end considering
set f's name to "*temp*"
set (duplicate f)'s name to newName
set f's name to fName
set theFile to newName
open file theFile
tell document 1 of application "QuarkXPress"
--for example, to check to see if the style sheet contains the words "Subttl" and "ttl"
set styleNamesToCheck to {"ttl"}
--get all style sheet names
set allStyleSheets to name of every style spec
-->{"Normal","custom style sheet name 1","custom style sheet name 2" }
--check for 'contains'' as needed
set x to 1
repeat with aName in allStyleSheets
repeat with aWord in styleNamesToCheck
if aName contains aWord then
display dialog "The \"" & aName & "\" style sheet contains \"" & aWord & "\". It is a OLD HTML Standard. "
set x to 0
end if
end repeat
end repeat
close saving no
if x is equal to 1 then
display dialog "All style sheets are with New HTML Standard." buttons {"Cancel", "OK"} default button 2 with icon 2
end if
end tell
tell application "Finder"
delete file theFile
end tell
end tell
end tell
Please can anybody knows to sort out this issue…?