Re: Re: Checking 2 folders and copy if new
Re: Re: Checking 2 folders and copy if new
- Subject: Re: Re: Checking 2 folders and copy if new
- From: Lachlan Deck <email@hidden>
- Date: Thu, 16 May 2002 11:14:19 +1000
Hi there,
From: Bjorn Van Blanckenberg <email@hidden>
Still having trouble
Applescript gives the error
write "file1 -> File server:folder:second folder:another
folder:last
folder::filename wasn't found.
Those :: is probably the problem
Property used for the folders are
property folderOne : ("server:folder:second folder:another folder:last
folder:")
Looks okay.
If I remove last : in property I get a parameter error on
set f1 to (folderOne & this_item) as alias
-> alias is giving the error I think
set f2 to (folderTwo & this_item) as alias
You could change that to:
set f1 to (folderOne & ":" & this_item) as alias
Note: it must be as alias otherwise the following command - getting the
modification date etc won't work.
If I remove the "as alias"
I get error
--> Can't get modification date of "server:folder:second folder:another
folder:last folderfilename".
As said above.
Try that little change and see how it goes.
Here's the whole thing again - just in case.
I've only tested this on Mac OS X
This should work - if you still have troubles I'll boot into 9...
===============================
property folderOne : (path to desktop as string) & "TESTF:"
property folderTwo : (path to desktop as string) & "TEST2:"
on run
sync_folders(folderOne, folderTwo, false)
end run
on sync_folders(fromF, toF, both_ways)
set theItems to sync_folders_aux(fromF, toF)
if theItems is not equal to {} then
copy_files(fromF, toF, theItems)
end if
if both_ways is not equal to false then
set theItems to sync_folders_aux(toF, fromF)
if theItems is not equal to {} then
copy_files(toF, fromF, theItems)
end if
end if
end sync_folders
-- for Mac OS 9 & X
on copy_files(fromF, toF, theList)
tell application "Finder"
repeat with i from 1 to the number of items in theList
duplicate ((fromF & ":" & (item i of the_list)) as alias)
to ,
(toF as alias) with replacing
end repeat
end tell
end copy_files
(* -- for Mac OS X only
on copy_files(fromF, toF, theList)
set thePath to (POSIX path of fromF) as string
set theStr to "cd " & thePath & "; cp"
repeat with i from 1 to the number of items in theList
set theStr to theStr & " " & ((item i of theList) as string)
end repeat
set theStr to theStr & " " & ((POSIX path of toF) as string)
--display dialog theStr
do shell script theStr
end copy_files
*)
on sync_folders_aux(fromF, toF)
set srcItems to {}
tell application "Finder"
set list_one to (list folder fromF as alias)
set list_two to (list folder toF as alias)
repeat with i from 1 to number of items in list_one
set this_item to (item i of list_one) as string
if list_two does not contain this_item then
set the end of srcItems to this_item
else
set f1 to (folderOne & this_item) as alias
set f2 to (folderTwo & this_item) as alias
set mod1 to (modification date of f1)
set mod2 to (modification date of f2)
if mod1 is greater than mod2 then
set the end of srcItems to this_item
end if
end if
end repeat
end tell
return srcItems
end sync_folders_aux
===============================
--
thanks
Bjorn Van Blanckenberg
with regards,
--
Lachlan Deck
email@hidden
_______________________________________________
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.