Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

applesaregood

macrumors newbie
Original poster
Dec 6, 2007
1
0
Hello,

I have a server running 10.5. I have a hard drive of old Home folders for about 500 users that is from an older 10.3 server.

Users want access to their old files. Just copying over the Home folders works fine. The issue I'm having is I don't want the Library folder to be copied over, because it contains old preferences that are causing a problem.

So basically I have two folders that look like this:

/Users
jdoe
dsmith
bjones

/oldUsers
jdoe
dsmith
bjones

Within each Home folder for each user I have a Documents, Movies, Pictures, Desktop, and Library folder. I need to copy the contents of /oldUsers/jdoe to /Users/jdoe, but not the Library folder.

So I think I need a bash or AppleScript to do this. Programming really isn't my strong point and I'm just struggling reading sites on bash scripts.

Thanks all
 

casperghst42

macrumors regular
Jan 11, 2006
159
111
Hi,

Have a look at 'rsync', if the uid/gid's are the same on both boxes, then this was what it was written to do.

Otherwise a shell script would probably make more sense than AppleScript.

Casper

Hello,

I have a server running 10.5. I have a hard drive of old Home folders for about 500 users that is from an older 10.3 server.

Users want access to their old files. Just copying over the Home folders works fine. The issue I'm having is I don't want the Library folder to be copied over, because it contains old preferences that are causing a problem.

So basically I have two folders that look like this:

/Users
jdoe
dsmith
bjones

/oldUsers
jdoe
dsmith
bjones

Within each Home folder for each user I have a Documents, Movies, Pictures, Desktop, and Library folder. I need to copy the contents of /oldUsers/jdoe to /Users/jdoe, but not the Library folder.

So I think I need a bash or AppleScript to do this. Programming really isn't my strong point and I'm just struggling reading sites on bash scripts.

Thanks all
 

satyam90

macrumors regular
Jul 30, 2007
242
0
Bangalore, India
Use the following shell script.
Copy the script to "/"
Now while running script Enter source directory as "oldUsers" and destination directory as "Users"

Now it will copy all the files from source to destination leaving "Library"

Code:
#!/bin/sh

echo "Enter Source Directory"
read src
echo "Enter Destination Directory"
read dest


list(){
        cd $1
        for files in `ls -al | awk '{print $9}'`
        do
                if [[ -d $files ]] && [[ ! $files = "Library" ]] && [[ ! $files = "." ]] && [[ ! $files = ".." ]]
                then
                        createdir=`echo $PWD | sed 's/'$src'/'$dest'/g'`
                        if [[ ! `ls $createdir/$files` ]]
                        then
                                mkdir -p $createdir/$files
                        fi
                        list $files
                else
                        if [[ -f $files ]]
                        then
                                destdir=`echo $PWD | sed 's/'$src'/'$dest'/g'`
                                cp $files $destdir/$files
                                echo "#"
                        fi
                fi
        done
        cd ..
}

list $src
 

HiRez

macrumors 603
Jan 6, 2004
6,265
2,630
Western US
As an alternative, you could try an AppleScript to do it:
Code:
set sourceFolder to choose folder with prompt "Choose the source folder"
set destFolder to choose folder with prompt "Choose the destination folder"
set buttonReturned to (display dialog "Preparing to copy all subfolders and files of '" & (the name of (get the info for sourceFolder)) & "' to '" & (the name of (get the info for destFolder)) & "', except the 'Library' folder. Existing folders with the same name will be replaced. Make sure you know what you're doing before proceeding!")

if button returned of result is not "OK" then
	quit
end if

tell application "Finder"
	set subitems to every item in sourceFolder
	repeat with anItem in subitems
		if (the name of anItem as string) is not "Library" then
			duplicate anItem to destFolder with replacing
		end if
	end repeat
end tell
That's totally untested, by the way. You might run into some permissions problems. At the very least, you'd have to be logged in as root to run it on user folders, I think.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.