I tried to use the search, but i didn’t find out any script for the following problem:
I want a script (AS) that converts via Freehand 11 a bunch or a folder of Freehand Files to PDF (for example to make customer-preview-pdfs of business cards) - the pdfs must not will be print-ready.
set myFolder to (choose folder "Select folder for processing:")
set unrecognized_files to (myFolder as string) & "unrecognized files" --> create this folder in the top level of myFolder
set old_freehand_list to {"FH5", "FH6", "FH7", "FH8", "FH9", "FH10"}
tell application "Finder" to set myFolderList to (every item of entire contents of myFolder whose kind is not "folder")
repeat with i from 1 to the number of items of myFolderList
set myFile to item i of myFolderList as alias
tell application "Finder" to set file_name to name of myFile
set file_creator to file creator of (info for myFile)
if check_file_creator(old_freehand_list, file_creator) then
tell application "System Events"
set file type of myFile to "AGD6"
set creator type of myFile to "FH11"
end tell
Process_Files_as_pdf(myFile, myFolder)
else
if file_creator = "FH11" then
Process_Files_as_pdf(myFile, myFolder)
else
tell application "Finder" to move myFile to folder unrecognized_files
end if
end if
end repeat
on check_file_creator(old_freehand_list, file_creator)
repeat with i from 1 to the number of items of old_freehand_list
set creator_type to item i of old_freehand_list
if file_creator contains creator_type then
return true
end if
end repeat
try
set theresult to the result
on error
return false
end try
end check_file_creator
on Process_Files_as_pdf(myFile, myFolder)
tell application "Finder" to set file_name to name of myFile
tell application "FreeHand MX"
activate
open myFile without Dialogs
save document 1 in file (myFolder & file_name) as "PDFWriter"
close saving no
end tell
end Process_Files_as_pdf
This has got a bit more in it than you need, but I think it’ll do the trick!
Thanks,
Nik
unfortunately the script quits with the message: žFreeHand MX" hat einen Fehler erhalten: Es ist ein Fehler ž2" aufgetreten. (FH MX got an error. It happens error 2).
the following line was highlighted after the script has stopped:
save document 1 in file (myFolder & file_name) as “PDFWriter”
set myFolder to (choose folder "Select folder for processing:")
set myFolder_path to myFolder as string
set unrecognized_files to (myFolder as string) & "unrecognized files" --> create this folder in the top level of myFolder
set old_freehand_list to {"FH5", "FH6", "FH7", "FH8", "FH9", "FH10"}
tell application "Finder" to set myFolderList to every file of myFolder
repeat with myFile in myFolderList
tell application "Finder" to set file_name to name of myFile
set file_creator to file creator of (info for (myFile as alias))
if file_creator is in old_freehand_list then
tell application "System Events"
set file type of myFile to "AGD6"
set creator type of myFile to "FH11"
end tell
Process_Files_as_pdf(myFile, file_name, myFolder_path)
else
if file_creator is equal to "FH11" then
Process_Files_as_pdf(myFile, file_name, myFolder_path)
else
tell application "Finder" to move myFile to folder unrecognized_files
end if
end if
end repeat
on Process_Files_as_pdf(myFile, file_name, myFolder_path)
tell application "FreeHand MX"
activate
open myFile without Dialogs
save document 1 in file (myFolder_path & file_name & ".pdf") as "PDFWriter"
close saving no
end tell
end Process_Files_as_pdf
Thanks for the post Stefan but some reason Freehand doesn’t like you syntax, I’ve changed the code to incorporate the folder alias as a string. Your other suggestion is much more efficient code though!
Nik
but i’ve got the same error (2) at the same line (save document 1 in file (myFolder_path & file_name & “.pdf”) as “PDFWriter”) while running the script.
Hi Christian,
This is strange as both the versions that I posted are working at my end. Could you please try this basic version and see if you get the same results?
set thefile to choose file
set myfullpath to (path to desktop as string)
set file_name to "mynewfile.pdf"
tell application "FreeHand MX"
open thefile
--save document 1 in file (myfullpath & file_name) as GenericEPS
save document 1 in file (myfullpath & file_name) as "PDFWriter"
close document 1 saving no
end tell