• 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: Finder: Delete files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Finder: Delete files


  • Subject: Re: Finder: Delete files
  • From: Nigel Garvey <email@hidden>
  • Date: Mon, 25 Jun 2001 14:24:09 +0100

Olivier Berquin wrote on Mon, 25 Jun 2001 09:37:59 +0200:

>Hi all,
>
>I would like to delete (in a folder) all the files that the date is not
>"today". I've this, but it not work fine:
>
>tell application "Finder"
> delete (every file of folder (choose folder) whose ,
> (modification date) < ((current date) - (1 * days))) -- 24 hours
> -- empty trash
>end tell

As Hugh's already mentioned, the Finder's 'whose' clause is bugged and
doesn't work reliably with numeric comparisons, such as dates. (Did I
hear this was fixed in 9.1?)

If you're likely to be deleting more files than you keep, the following
approach would save having to loop through every single modification date
in the folder:

tell (current date) to set {time, today} to {0, it}

tell application "Finder"
set fileList to sort files of (choose folder) by modification date
repeat with i from 1 to (count the result)
if the modification date of item i of fileList comes before today
then exit repeat
end repeat
delete items i through -1 of fileList
end tell

NG


  • Prev by Date: finder under 10
  • Next by Date: Re: How to get the index of an item in a list
  • Previous by thread: Re: Finder: Delete files
  • Next by thread: How to get the index of an item in a list
  • Index(es):
    • Date
    • Thread