Re: Backing up only new files
Re: Backing up only new files
- Subject: Re: Backing up only new files
- From: Graff <email@hidden>
- Date: Tue, 27 Apr 2004 14:54:59 -0400
On Apr 27, 2004, at 1:37 PM, Bernard Azancot wrote:
Le 27 avr. 04, ` 07:00, email@hidden a
icrit :
set up the recursion depending on the structure of your file system.
Primarily, decide how many folders deep do you want to check for
modified files before you simply copy the whole folder. It will be a
big time saver. Once you have the recursion set up in a repeat loop,
here's the Finder terminology, assuming originalItem and backupItem
are
references to the corresponding files.
tell application "Finder"
if ((modification date of item backupItem) < (modification date of
item originalItem)) then
-- originalItem is newer
else
--backupItem presumably has same modification date (or is newer,
which
would be wierd)
end if
end tell
Cheers,
Joe
Thank you very much, Joe.
I see what you mean, but...could you give me a simple example of how
to set up the recurssion in a repeat loop.
Here is an example function to recursively walk a folder hierarchy.
Just put what you want to do with each folder in the "DoFunction"
function. Then call the "RecursiveWalk" function with the top-level
folder you want it to start at:
---------------
-- here is the recursive function that does the work
on RecursiveWalk(theFolder)
tell application "Finder"
DoFunction(theFolder)
set allFolders to every folder of theFolder
repeat with newFolder in allFolders
my RecursiveWalk(newFolder)
end repeat
end tell
end RecursiveWalk
-- do your operation on the folder here
on DoFunction(theFolder)
-- do something here
end DoFunction
---------------
The only problem is this may choke on extremely involved folder
hierarchies. You may be better off using this list-based solution:
--------------
-- here is the function that does the work
on ListWalk(theFolder)
set folderList to {}
copy theFolder to the end of folderList
tell application "Finder"
repeat while length of folderList is greater than 0
set currentFolder to the first item in folderList
set folderList to the rest of folderList
set newFolders to every folder of currentFolder
set folderList to folderList & newFolders
DoFunction(currentFolder)
end repeat
end tell
end ListWalk
-- do your operation on the folder here
on DoFunction(theFolder)
-- do something here
end DoFunction
--------------
- Ken
_______________________________________________
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.