• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Check folder if empty
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Check folder if empty


  • Subject: Re: Check folder if empty
  • From: kai <email@hidden>
  • Date: Sat, 23 Oct 2004 00:04:23 +0100


On Fri, 22 Oct 2004 20:22:09 +0200, Peter Mathiessen wrote:

I´m trying to make a script that will auto distill postscriptfiles in the
distiller. For that I need a script that checks the "in" folder and the
"out" folder in Acrobat Distiller watched folders.


I want to place a numbers of postscriptfiles in the "in" folder and let the
distiller generate PDF-files. When the task is complete every file will be
moved by the script to differrent folders.


I need some code to make certain that the "in" folder is empty and the
distiller is done with the task. I have tried many different solutions but
no one seems to work correctly.


How do I make the code that count the files in the "in" folder, if some
files is still there it will recount until the folder is empty and only if
the folder is empty it will continue the script.


This some part of the script with my, not so good, solution:

if the_Count is not equal to 0 then
repeat until the_Count = 0
set the_Count to the count of every item of searchFolder
end repeat
end if

-----------------------------------------------------------------------

The whole script:

copy "Macintosh HD:Script_folder:Distilleri:" as text to the_vol

set the_Count to 0
set searchFolder to (the_vol & "Tryck:In:")
set myList to list folder searchFolder without invisibles
repeat with myFilename in every item of myList
set countfile to alias (searchFolder & myFilename)
set the_Count to the_Count + 1
end repeat

if the_Count = 0 then
set searchFolder to alias (the_vol & "Tryck:Out")
set destinationfolder to alias (the_vol & "Klara PDF filer")
set destination_ps_folder to alias (the_vol & "temp_postscript")
set myListfolder to list folder searchFolder without invisibles
repeat with myFilename in every item in myListfolder
set myFile to alias (the_vol & "Tryck:Out:" & myFilename)
tell application "Finder"
if name of myFile ends with "pdf" then
try
set name of myFile to ("Tryck_" & myFilename)
move myFile to destinationfolder with replacing
end try
end if
if name of myFile ends with "log" then
try
move myFile to destinationfolder with replacing
end try
end if
if name of myFile ends with "ps" then
try
move myFile to destination_ps_folder with replacing
end try
end if
end tell
end repeat
end if

if the_Count is not equal to 0 then
repeat until the_Count = 0
set the_Count to the count of every item of searchFolder
end repeat
end if

-----------------------------------------------------------------------

Not sure if I've interpreted your aims accurately, Peter - but you might like to try something like this:


----------------------------------

-- save as 'stay open' application

property the_vol : "Macintosh HD:Script_folder:Distilleri:"
property inFolder : alias (the_vol & "Tryck:In")
property outFolder : alias (the_vol & "Tryck:Out")
property destinationfolder : alias (the_vol & "Klara PDF filer")
property destination_ps_folder : alias (the_vol & "temp_postscript")

to renameAndMove()
tell application "Finder"
repeat with f in (get outFolder's files whose name ends with "pdf")
set f's name to "Tryck_" & f's name
end repeat
move (outFolder's files whose name ends with "pdf" or name ends with "log") to destinationfolder with replacing
move (outFolder's files whose name ends with "ps") to destination_ps_folder with replacing
end tell
end renameAndMove


on idle
if (count (list folder inFolder without invisibles)) is 0 and (count (list folder outFolder without invisibles)) is greater than 0 then renameAndMove()
60 -- number of seconds before next check (modify as required)
end idle


----------------------------------

---
kai

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: Creating a chart or graphic line...
  • Next by Date: Re: Legacy conversion of Quark 4 to InDesign 2 files question
  • Previous by thread: Re: Check folder if empty
  • Next by thread: more scripting iCal
  • Index(es):
    • Date
    • Thread