Re: Finder: Delete files
Re: Finder: Delete files
- Subject: Re: Finder: Delete files
- From: Hugh Dixon <email@hidden>
- Date: Mon, 25 Jun 2001 11:37:12 +0000
On 25/6/01 7:37 am, Olivier Berquin wrote
>
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
>
Hi
Finder doesn't like "whose" in date comparisons. Try this:
set {the_folder, folder_name, file_list} to {(choose folder), the_folder as
text, list folder the_folder} -- one line
set old_list to {}
set yesterday to (current date) - (1 * days)
repeat with each_name in file_list
set file_path to folder_name & each_name
if (modification date of (info for alias file_path)) < yesterday then
set old_list to old_list & each_name --one line
end if
end repeat
tell application "Finder" to delete (every file of folder the_folder whose
name is in old_list) -- one line
Hope this helps.
Hugh
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.
www.mimesweeper.com
**********************************************************************