My script print incoming pdf´s and move them to the folder “printed”.
But I like to control the file type and not only the filename (.pdf) so that are only pdf-files printed.
How can i do that?
Please help me!
Many thanks…
property copy_checks_indicator : true
property item_check_delay_time : 2
property folder_check_delay_time : 3
property special_label_index : 7
property done_foldername : "Printed"
on adding folder items to this_folder after receiving added_items
tell application "Finder"
if not (exists folder done_foldername of this_folder) then
make new folder at this_folder with properties {name:done_foldername}
end if
set the target_folder to folder done_foldername of this_folder
end tell
repeat with this_item in added_items
tell application "Finder"
-->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
(*here i want control the file type "PDF" - How can i do that? Please help me!*)
set fileName to name of this_item
if fileName ends with ".pdf" then
try
tell application "Acrobat 5.0"
open this_item
print pages front document with shrink to fit
close front document
end tell
end try
try
move this_item to the target_folder
on error
set fileNumber to (count (files of target_folder whose name contains fileName)) as string
set newName to fileName & fileNumber
set name of this_item to newName
move file newName of this_folder to target_folder
end try
end if
end tell
end repeat
end adding folder items to
on check_added_items(the added_items)
-- check the transfer status of every added file to determine
-- if each file has completed being moved into the attached folder
set the notbusy_items to {}
repeat with i from 1 to the number of items in the added_items
set this_item to (item i of the added_items)
if my check_busy_status(this_item) is false then
set the end of the notbusy_items to this_item
end if
end repeat
return the notbusy_items
end check_added_items
on check_busy_status(this_item)
-- a folder can contain items partially transfered
-- this routine will wait for all the folder contents to transfer
if the last character of (this_item as text) is ":" then
set the check_flag to false
repeat
-- look for any files within the folder that are still transferring
tell application "Finder"
try
set the busy_items to the name of every file of the entire contents of this_item ¬
whose file type begins with "bzy"
on error
set the busy_items to {}
end try
end tell
if the check_flag is true and the busy_items is {} then return false
-- pause for the indicated time
delay the folder_check_delay_time
-- set the flag and check again
set the check_flag to true
end repeat
else -- the passed item is a single file, suitcase, clipping, etc.
-- check the label of the item. If it is the marked label, then it's already been processed so ignore.
tell application "Finder"
if (the label index of this_item) as integer is the special_label_index then
return "ignore"
end if
end tell
set the check_flag to false
repeat
tell application "Finder"
set the item_file_type to the file type of this_item
end tell
if the check_flag is true and ¬
the item_file_type does not start with "bzy" then
tell application "Finder"
set the label index of this_item to the special_label_index
end tell
-- allow the Finder time to change the label
delay the item_check_delay_time
return false
else if the item_file_type does not start with "bzy" then
-- set the flag and check again
set the check_flag to true
end if
-- pause for the indicated time
delay the item_check_delay_time
end repeat
end if
end check_busy_status