How to copy without destroying same-named folders

Discussion in 'Mac Apps and Mac App Store' started by killmoms, Oct 25, 2004.

  1. killmoms macrumors 68040


    Jun 23, 2003
    Washington, DC
    Okay, question about a slightly odd situation I'm in. I have an archive of a website I was very fond of back in the day on 14 CDs. Of course, each CD only has certain parts of the website on it, but many of the same folders (just more files in those folders). How can I copy all these CDs' files into the same directory tree, since Finder seems to only replace a folder with the new version? Unix commands acceptable, if necessary.
  2. scan300 macrumors 6502

    Mar 25, 2003
    Melbourne, Australia
    Generally you could use a backup utility to do this. But I thought I would try this as an applescript exercise.

    The following script, when run, will ask for a source folder: the folder which contains your original html files. (disk one. (you can select the disk icon if that's the root of your site tree).

    Then it will ask for a destination folder. This is where you will build your conglomerated site.

    After it has finished copying, select your next disk and repeat the process. The script will basically keep adding to your destination file structure, and add folders where needed, but it won't replace any existing files or folders in the destination folder.

    Please note this script has no progress indicator, it will tell you when it's finished, that's all. Basically select the source and destination the same way you would choose a location to copy a folder to normally in the finder. This script will just make sure it doesn't overwrite anything already there.

    Copy the following code into your applescript editor and save as application which you can double click to run, or just compile and run it straight from the script editor. Leave me a post if it works.

    property myFolderName : ""
    property text3 : ""
    choose folder with prompt "select a source"
    set mySourceFolder to result
    global mySourceFolder
    set myWorkingFolder to mySourceFolder
    choose folder with prompt "select a destination"
    set myDestinationFolder to result
    global myDestinationFolder
    my ListFolder(mySourceFolder)
    display dialog "Finished"
    on ListFolder(myWorkingFolder)
    	tell application "Finder"
    		set myFolderName to name of myWorkingFolder
    		set myFolderContents to every file of myWorkingFolder
    		set myFolderList to every folder of myWorkingFolder
    		if (myWorkingFolder is not mySourceFolder) then
    			set text1 to length of (mySourceFolder as string)
    			set text2 to length of (myWorkingFolder as string)
    			set text2a to myWorkingFolder as string
    			set text3 to characters (text1 + 1) thru text2 of text2a as string
    			set newFPath to ((myDestinationFolder as string) & text3)
    			set ftext1 to length of (newFPath as string)
    			set ftext2 to (length of myFolderName) + 1
    			set ftext2a to newFPath as string
    			set ftext3 to characters 1 thru (ftext1 - ftext2) of ftext2a as string
    				make new folder in folder ftext3 with properties {name:myFolderName}
    			end try
    		end if
    		repeat with x in myFolderContents
    			set newPath to ((myDestinationFolder as string) & text3)
    				duplicate x to folder newPath without replacing
    			end try
    		end repeat
    		repeat with y in myFolderList
    			ListFolder(y) of me
    		end repeat
    	end tell
    end ListFolder
  3. dubbz macrumors 68020


    Sep 3, 2003
    Alta, Norway
    Heh, that used to be a big source of confusion and annoyance to me. I ended up using Rsync X (It's a OS X GUI for the UNIX rsync utility). It's perhaps a bit of overkill, but it works :)
  4. killmoms thread starter macrumors 68040


    Jun 23, 2003
    Washington, DC
    Thanks for the assistance, but I asked a Linux using friend of mine, and he suggested cp -R source destination. Worked like a charm. KISS I guess. Just thought you guys would like to know.

Share This Page