Duplicate and rename folder path
Duplicate and rename folder path
- Subject: Duplicate and rename folder path
- From: Phil Burk <email@hidden>
- Date: Mon, 26 Feb 2001 18:16:16 -0500
OK, here's a question for which I'm not sure there's an answer.
I have a folder on a server volume that is being duplicated to two different
locations: a local workstation and another server volume.
I am able to correctly duplicate the contents from the source to the
destinations and I can also log the source in a format I desire. My problem
results from having a folder and its contents duplicated and not just its
contents. When I log the results of the duplication to the two destinations
the source folder is copied too.
My question is this: Can I force AS to duplicate the folder in question and
then remove the source folder (without its contents)? Very convoluted
question. Maybe I could tell AS to duplicate just the contents of the
folder?
FYI, yes, I am STILL working on this... ;)
ACK.
Script follows...
global theDate
global theSource, Dest1, Dest2
global LogFileSource, LogFileDest1, LogFileDest2
global fileList
global sourceLength, dest1Length, dest2Length
----------------------------------------------------------------------------
-------------------------
getDate()
getVolumes()
----------------------------------------------------------------------------
-------------------------
set theSource to the contents of alias "PrePress:(Testing):"
set Dest1 to alias "DMG:Destination:"
set Dest2 to alias "Archive:(Destination):"
set sourceLength to length of (theSource as string)
set dest1true to "DMG:Destination:(Testing):"
set dest1Length to length of (dest1true as string)
set dest2true to "Archive:(Destination):(Testing):"
set dest2Length to length of (dest2true as string)
set LogFileSource to a reference to (path to desktop as string) & "Source "
& theDate
set LogFileDest1 to a reference to (path to desktop as string) & "Dest1 " &
theDate
set LogFileDest2 to a reference to (path to desktop as string) & "Dest2 " &
theDate
set fileList to {}
----------------------------------------------------------------------------
-------------------------
dateToSourceLog()
dateToDest1Log()
dateToDest2Log()
set theContentsSource to logSourceContents((theSource) as string)
duplicateToDest1()
set theContentsDest1 to logDest1Contents((Dest1) as string)
duplicateToDest2()
set theContentsDest2 to logDest2Contents((Dest2) as string)
compareSourceToDest1()
compareSourceToDest2()
----------------------------------------------------------------------------
-------------------------
on getDate()
set todaysDate to (current date)
set {d, m, y} to {day, month, year} of todaysDate
set monthList to {January, February, March, April, May, ,
June, July, August, September, October, November, ,
December}
repeat with i from 1 to 12
if m = (item i of monthList) then
set monthString to text -2 thru -1 of ("0" & i)
exit repeat
end if
end repeat
set dayString to text -2 thru -1 of ("0" & d)
set todaysDate to dayString & "/" & monthString & "/" & y
set theDate to format date (current date) with format "%m-%d-%y"
end getDate
----------------------------------------------------------------------------
-------------------------
on dateToSourceLog()
open for access file LogFileSource with write permission
set eof of file LogFileSource to 0
write ((current date) as text) to LogFileSource starting at eof
close access file LogFileSource
end dateToSourceLog
----------------------------------------------------------------------------
-------------------------
on dateToDest1Log()
open for access file LogFileDest1 with write permission
set eof of file LogFileDest1 to 0
write ((current date) as text) to LogFileDest1 starting at eof
close access file LogFileDest1
end dateToDest1Log
----------------------------------------------------------------------------
-------------------------
on dateToDest2Log()
open for access file LogFileDest2 with write permission
set eof of file LogFileDest2 to 0
write ((current date) as text) to LogFileDest2 starting at eof
close access file LogFileDest2
end dateToDest2Log
----------------------------------------------------------------------------
----------------------------
on getVolumes()
try
mount volume "Archive" on server "PREPRESS_PRATT" in AppleTalk zone
"NOVELL" as user name "********" with password "********"
mount volume "PrePress" on server "PREPRESS_PRATT" in AppleTalk zone
"NOVELL" as user name "********" with password "********"
end try
end getVolumes
----------------------------------------------------------------------------
----------------------------
on logSourceContents(pathToFolder)
set savedTextItemDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to {return}
set theListRef to a reference to list folder pathToFolder without
invisibles
repeat with nextItem in theListRef
set itemPath to pathToFolder & nextItem
set itemInfo to info for alias itemPath
if folder of itemInfo then
open for access file LogFileSource with write permission
set x to sourceLength + 1
set newItemPath to (text x thru -1) of itemPath
write (return & newItemPath) to LogFileSource starting at eof
close access LogFileSource
logSourceContents(itemPath & ":")
else
open for access file LogFileSource with write permission
set x to sourceLength + 1
set newItemPath to (text x thru -1) of itemPath
write (return & newItemPath) to LogFileSource starting at eof
close access LogFileSource
set the fileList to fileList & itemPath
end if
end repeat
set AppleScript's text item delimiters to savedTextItemDelimiters
end logSourceContents
----------------------------------------------------------------------------
----------------------------
on logDest1Contents(pathToFolder)
set savedTextItemDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to {return}
set theListRef to a reference to list folder pathToFolder without
invisibles
repeat with nextItem in theListRef
set itemPath to pathToFolder & nextItem
set itemInfo to info for alias itemPath
if folder of itemInfo then
open for access file LogFileDest1 with write permission
set x to dest1Length - 1
set newItemPath to (text x thru -1) of itemPath
write (return & newItemPath) to LogFileDest1 starting at eof
close access LogFileDest1
logDest1Contents(itemPath & ":")
else
open for access file LogFileDest1 with write permission
set x to dest1Length + 1
set newItemPath to (text x thru -1) of itemPath
write (return & newItemPath) to LogFileDest1 starting at eof
close access LogFileDest1
set the fileList to fileList & itemPath
end if
end repeat
return fileList
set AppleScript's text item delimiters to savedTextItemDelimiters
end logDest1Contents
----------------------------------------------------------------------------
----------------------------
on logDest2Contents(pathToFolder)
set savedTextItemDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to {return}
set theListRef to a reference to list folder pathToFolder without
invisibles
repeat with nextItem in theListRef
set itemPath to pathToFolder & nextItem
set itemInfo to info for alias itemPath
if folder of itemInfo then
open for access file LogFileDest2 with write permission
set x to dest2Length - 1
set newItemPath to (text x thru -1) of itemPath
write (return & newItemPath) to LogFileDest2 starting at eof
close access LogFileDest2
logDest2Contents(itemPath & ":")
else
open for access file LogFileDest2 with write permission
set x to dest2Length + 1
set newItemPath to (text x thru -1) of itemPath
write (return & newItemPath) to LogFileDest2 starting at eof
close access LogFileDest2
set the fileList to fileList & itemPath
end if
end repeat
return fileList
set AppleScript's text item delimiters to savedTextItemDelimiters
end logDest2Contents
----------------------------------------------------------------------------
-------------------------
on duplicateToDest1()
tell application "Finder"
with timeout of 36000 seconds
duplicate (theSource) to (Dest1) with replacing
end timeout
end tell
end duplicateToDest1
----------------------------------------------------------------------------
-------------------------
on duplicateToDest2()
tell application "Finder"
with timeout of 36000 seconds
duplicate (theSource) to (Dest2) with replacing
end timeout
end tell
end duplicateToDest2
----------------------------------------------------------------------------
-------------------------
on compareSourceToDest1()
tell application "Tex-Edit Plus"
open file "OS 9 (disk 1):Desktop Folder:Source 02-26-01"
open file "OS 9 (disk 1):Desktop Folder:Dest1 02-26-01"
if the contents of window "Dest1 02-26-01" = the contents of window
"Source 02-26-01" then
display dialog "They're equal" buttons {"OK"}
else
display dialog "Gotta problem with Source and Destination 1..."
giving up after 5
end if
with timeout of 15 seconds
tell application "Tex-Edit Plus"
close file "OS 9 (disk1):Desktop Folder:Source 02-26-01"
close file "OS 9 (disk1):Desktop Folder:Dest1 02-26-01"
end tell
end timeout
end tell
end compareSourceToDest1
----------------------------------------------------------------------------
-------------------------
on compareSourceToDest2()
tell application "Tex-Edit Plus"
open file "OS 9 (disk 1):Desktop Folder:Source 02-26-01"
open file "OS 9 (disk 1):Desktop Folder:Dest2 02-26-01"
if the contents of window "Dest2 02-26-01" = the contents of window
"Source 02-26-01" then
display dialog "They're equal" buttons {"OK"}
else
display dialog "Gotta problem with Source and Destination 2..."
end if
close file "OS 9 (disk1):Desktop Folder:Source 02-26-01"
close file "OS 9 (disk1):Desktop Folder:Dest2 02-26-01"
end tell
end compareSourceToDest2
----------------------------------------------------------------------------
Phil Burk
DesktopMedia, Inc.
email@hidden
"Let us all be happy, and live within our means, even if we have to borrow
money to do it with."
- Artemus Ward, "Artemus Ward in London" (1872)