Duplicating files from path
Duplicating files from path
- Subject: Duplicating files from path
- From: Phil Burk <email@hidden>
- Date: Tue, 20 Feb 2001 11:57:35 -0500
Greetings,
I mostly lurk here but I am currently working on "file duplicator" script
that will copy and verify files on a server to a local workstation for CD
burning for Archival purposes. I have cobbled together parts from script
examples I have found on the web and generated some code of my own also. So
if you see code that might be yours, take it as a compliment... ;)
The problem I seem to be running into is this: I have generated a variable
that contains a path to a file (from a list) on the server. Using a
duplicate command I am able to duplicate the file to the local workstation
except that it *does not* duplicate the folders containing the file, only
the file itself.
I know this is incredibly obvious but I have not been able to figure out how
to duplicate the file in the variable as its *complete* path on the local
workstation. Here's my script:
global theDate
global theList
global theSource, Dest1, Dest2, Destination1
set theList to ""
getDate()
getVolumes()
setAndCheckSources()
-- doDuplicate()
open (theSource) --, Dest1, Dest2)
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"
set file_ref to open for access file (("OS 9 (disk 1):Desktop Folder:" &
"Source " & theDate) as string) with write permission
write (return & (current date)) to file_ref starting at eof
close access file_ref
end getDate
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 setAndCheckSources()
set theSource to {alias "PrePress:(Testing):"}
set theSourcePath to "PrePress:(Testing)"
set Dest1 to {alias "DMG:Destination:"}
set Destination1 to "DMG:Destination:"
set Dest2 to {alias "Archive:(Destination):"}
set sourceSize to (size of (info for theSource))
set destSpace1 to (free_space_in_kb of (Get Volume Info of "DMG:")) *
1024
set destSpace2 to (free_space_in_kb of (Get Volume Info of "Games:")) *
1024
set destSpace2 to destSpace2 * 1024
if sourceSize < destSpace1 then
display dialog "There is enough space to begin. Start copying?"
-- doDuplicate(theSource, Dest1)
end if
-- if sourceSize < destSpace2 then doDuplicate(theSource, Dest2)
end setAndCheckSources
on doDuplicate(theSource, destination)
tell application "Finder"
with timeout of 36000 seconds
activate
set sources to {theSource}
repeat
try
duplicate alias theSource to folder destination with
replacing
exit repeat
on error errtext number errnum
display dialog errtext
quit
end try
end repeat
end timeout
end tell
end doDuplicate
on open (itemList)
repeat with anItem in itemList
set theItem to the (contents of anItem) as text
if character -1 of (theItem as text) is ":" then
tell application "Finder"
set newList to items of alias theItem
end tell
open (newList)
else
procFile(theItem)
end if
end repeat
end open
on procFile(theFile)
set file_ref to open for access file (("OS 9 (disk 1):Desktop Folder:" &
"Source " & theDate) as string) with write permission
write (return & theFile) to file_ref starting at eof
close access file_ref
doDuplicate(theFile, Destination1)
end procFile
on getFileSpecs()
set charFileName to count characters in theFile
set chartheSource to count characters in "PrePress:(Testing):"
set FileName to (characters 19 thru charFileName of theFile) as text
display dialog "New path to file: " & FileName
end getFileSpecs
----------------------------------------------------------------------------
Phil Burk
DesktopMedia, Inc.
email@hidden
"You have not converted a man because you have silenced him."
- John Morley, "On Compromise" (1874)