Re: Script to copy changed files?
Re: Script to copy changed files?
- Subject: Re: Script to copy changed files?
- From: Jan Pieter Kunst <email@hidden>
- Date: Thu, 14 Jun 2001 13:01:17 +0200
Chris Page (email@hidden) schreef op 13-06-2001 08:46 :
>
Anyone know of a script I could download that will recursively copy the
>
files/folders from one folder to another, only copying files that have
>
changed?
I recently wrote a script that recursively travels through a folder
hierarchy. I'm using it to have GraphicConverter do things with the files it
encounters, but the "traveling" part is separated from the "doing things
with files" part, so it should be easy to adapt it to other things.
Note: it works, but it might very well be possible to streamline it, use
more efficient or elegant code, etc. I'm still an Applescript newbie, and
open for suggestions.
Anyway, this is the "traveling" part. It is just the "skeleton" of a
droplet, it works with files, folders or both dropped unto it. If it
encounters a folder, it calls itself recursively; if it encounters a file,
you can have it call your own handler to do something with it.
JP
============================================================
on open (stuff)
tell application "Finder"
set stuff to stuff as list
repeat with n from 1 to count of stuff
set stuff_alias to item n of stuff as alias
my work_through_list(stuff_alias)
end repeat
end tell
end open
on work_through_list(stuff_alias)
tell application "Finder"
if (kind of stuff_alias) is "folder" then
(* recursive part *)
set stuff_list to every item of stuff_alias
repeat with n from 1 to count of stuff_list
set item_alias to item n of stuff_list as alias
my work_through_list(item_alias)
end repeat
else
(* hook your file handling stuff into the script here *)
my do_things_with_file(stuff_alias)
end if
end tell
end work_through_list
============================================================