Re: Missing file date
Re: Missing file date
- Subject: Re: Missing file date
- From: John Stewart <email@hidden>
- Date: Tue, 23 Sep 2003 19:18:19 -0400
On 9/23/03 at -0400 Timothy K. Wilkinson said this
>
I'm writing a script to go through my server's data drive and delete
>
files
>
that are older then 18 days. Currently I'm just listing them but I hope
>
to
>
have it delete them soon.
>
>
It works fine except for the times that there is no date. It returns a
>
value of "msng". This seems to happen on files that are invisible and
>
have
>
a "." in front of them. I've tried to test for that (see below) but
>
with
>
no success.
>
>
I'm using walk folders from Jon's Commands. I've set it to run without
>
invisibles but I'm getting hung up by the "." files.
>
>
Is there a way to skip over those "." files as well as the invisible
>
ones?
>
>
Here's what I have so far (thanks to Jon for the example script):
>
>
--begin--
<snip>
>
--end---
>
I am assuming that since you are worried about files that begin with a period that you are using OS X (10.2.x). If
that's so then this should work for you. If you are still using OS 9 then stick with Jon's walk folders osax call.
Watch out for wrapped lines. Any line in the script that abuts the left margin is wrapped.
(* start script *)
set targlist to {}
set targDate to ((date (date string of (current date))) - 18 * days)
set fp to (choose folder) -- insert your path here
tell application "Finder"
set fList to every file of entire contents of fp whose name does not start with "." -- no need for osax
(* I would have preferred a better whose clause here but it
didn't like "info for" and "creation date" parameters *)
repeat with targFile in fList
set temp to (contents of targFile) as alias
if (visible of (get info for temp)) is true then
if creation date of temp is less than targDate then set end of targlist to temp
(* this can be changed to either move to trash or immediately
delete files instead of building a list, the list was just for testing *)
-- if (creation date of temp is less than targDate) and (creation date of temp is not missing
value) then delete temp -- deletes the file immediately
-- if (creation date of temp is less than targDate) and (creation date of temp is not missing
value) then move temp to trash -- moves to trash
end if
end repeat
end tell
(* end script *)
John
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.