Hi…
I´m having trouble with something i guess is pretty simple for the experts here
I just want to move a file from A to B when it lands in folder A. . - ok, I can manage that
The problem is that the software that provides the file for folder A (Prinergy in this case), first creates a tempfolder to save the file in. (Temp_YCS… etc)
My folder action naturally reacts to that tempfolder and moves it straight away to B… -and that creates a lot of fun of course for Prinergy that can´t save its file because the tempfolder is gone
I have solved it temporarily by doing a delay in the script that wait out the tempfolder, but that means i have to wait the same amount of time for all files. (witch means i´m wasting time sometimes)
I want my folder action to react to the tempfolder… loops as long as the tempfolder exists and then move the file when the tempfolder is gone… (Prinergy removes the tempfolder itself).
The tempfolder always start with “Temp_YCS” so i guess i can use that for something
Anyone ??
if you post some code I can show you how to modify it ignore the temp folder
Here are the fake way
Some says and stuff in there that are really just for fun right now
on adding folder items to this_folder after receiving added_items
try
tell application “Finder”
delete every item of folder “G5_A2:Brukere:ServerA:Dokumenter:GARO ExtraKit2:Canon_Gloss_HF”
say “Deleting old files in Garo Hotfolder.” with waiting until completion
end tell
delay 120
tell application “Finder”
move added_items to “G5_A2:Brukere:ServerA:Dokumenter:GARO ExtraKit2:Canon_Gloss_HF”
end tell
tell application "Finder"
delete every item of this_folder
say "Deleting old files in Plot receciving folder." with waiting until completion
end tell
end try
end adding folder items to
basically all you need to do is before you move them reset the added_items to not include temp folder and or if the added items is just temp folder tell the function to return
on adding folder items to this_folder after receiving added_items
try
tell application "Finder"
delete every item of folder "G5_A2:Brukere:ServerA:Dokumenter:GARO ExtraKit2:Canon_Gloss_HF"
say "Deleting old files in Garo Hotfolder." with waiting until completion
end tell
delay 120
tell application "Finder"
set added_items to every added_items whose name does not contain "tempfolder"
move added_items to "G5_A2:Brukere:ServerA:Dokumenter:GARO ExtraKit2:Canon_Gloss_HF"
end tell
tell application "Finder"
delete every item of this_folder
say "Deleting old files in Plot receciving folder." with waiting until completion
end tell
end try
end adding folder items to
It did not work for some reason though…
it correctly ignored the tempfolder and did not move it, but it did not move the file whitin the tempfolder after the tempfolder was gone.
Seems like it doesnt react to that file?
Maybe i explained it poorly or /and my english is terrible
The file i want to move comes fra a software called Kodak prinergy.
The way prinergy does this is by first creating a folder with that “temp_ycs” name. Inside that folder prinergy saves the pdf i want to move and then deletes the tempfolder when it is finished saving the pdf.
the filesize can vary a lot and the file is coming over a sometimes busy network, so the time used for creating the pdf varys a lot.
Seems to me like the script don´t treat the file inside the tempfolder as a added item to my move folder
?
I have no clue ?
it looks like this now…
on adding folder items to this_folder after receiving added_items
try
tell application "Finder"
delete every item of folder "G5_A2:Brukere:ServerA:Dokumenter:GARO ExtraKit2:Canon_Gloss_HF"
say "Deleting old files in Garo Hotfolder." with waiting until completion
end tell
tell application "Finder"
set added_items to added_items whose name does not contain "TEMP_YCS"
move added_items to "G5_A2:Brukere:ServerA:Dokumenter:GARO ExtraKit2:Canon_Gloss_HF"
end tell
tell application "Finder"
delete every item of this_folder
say "Deleting old files in Plot receciving folder." with waiting until completion
end tell
end try
end adding folder items to
maybe i need a loop in there somewhere??
Hi,
this part cannot work, because you try to move the files to an literal string, not to a location reference.
Unfortunately the script doesn’t reach this line. It fails in the line before
added_items is a custom list and the whose filter doesn’t affect custom lists.
It throws an error and the script aborts silently in an folder action handler.
Therefore the try block is not needed at all.
A good way to debug folder action scripts is to comment out the action handler
and set the two action variables to predefined values
This should move the files correctly
property tempFolder : "G5_A2:Brukere:ServerA:Dokumenter:GARO ExtraKit2:Canon_Gloss_HF:"
on adding folder items to this_folder after receiving added_items
tell application "Finder" to delete every item of folder tempFolder
say "Deleting old files in Garo Hotfolder." with waiting until completion
tell application "Finder"
repeat with oneItem in added_items
if name of oneItem does not contain "TEMP_YCS" then
move oneItem to folder tempFolder
end if
end repeat
delete every item of this_folder
end tell
say "Deleting old files in Plot receciving folder." with waiting until completion
end adding folder items to
hmm…Thanks
this is a trick one i guess
that script moved the temfolder right away and prinergy failed because the tempfolder is gone before it can deliever the pdf to the tenmpfolder
This did the trick…
a loop that waits out the tempfolder and then moves every item of the folder.
Not added items as this would be the tempfolder.
on adding folder items to this_folder after receiving added_items
repeat
if added_items does not contain "TEMP_YCS" then
exit repeat
end if
end repeat
tell application "Finder"
delete every item of folder "G5_A2:Brukere:ServerA:Dokumenter:GARO ExtraKit2:Canon_Gloss_HF"
say "Deleting old files in Garo Hotfolder." with waiting until completion
end tell
tell application "Finder"
move every item of this_folder to "G5_A2:Brukere:ServerA:Dokumenter:GARO ExtraKit2:Canon_Gloss_HF"
end tell
tell application "Finder"
delete every item of this_folder
say "Deleting old files in Plot receciving folder." with waiting until completion
end tell
end adding folder items to
Thanks a lot for all help.
It was a bit of everything you said that did the trick in the end…
Now it works and thats good
Two notes:
¢ It’s always recommended to keep Scripting Additions commands like say out of application tell blocks
¢ the default setting of the waiting until completion parameter is true and the parameter will be ignored anyway unless Speech Recognition is on
Ok thanks…
the say stuff is just for testing really as the server that runs the folder action is a bit away from me…(other side of the room)
it was just ok to “hear” what was going on over there
When the function of the folder is ok i will remove these say commands
But actually the scripts still doesnt work properly…
it works for small files (as i tested with) , but for some strange reason it fails on big files…
have to look more in to this tomorrow