Copy and replace folders with parentheses in the name

I am in the middle of taking user accounts that are bound to one Windows AD domain, and re-binding them to another domain, still intending for the users to login with their network accounts.

I have been going about unbinding from a local administrator account, and deleting their local network user account. I delete it, but I leave the files in place. This leaves a folder for user “kaisersoze” that looks like this:

/users/kaisersoze (deleted)

The next time kaisersoze logs on, with the same username with the credentials to the new domain, I am taking items from the deleted profile folder and copying them over into the new profile folder.

I do this with terminal commands. I move a lot of items out of the Library

i run

sudo chflags nohidden /users/kaisersoze\ (deleted)/Library/*

To make the current library editable, I run

sudo chflags nohidden /users/kaisersoze/Library/*

Then I run a chown commands before or after the transfer on the deleted folders. I end by changing the flag on the /users/kaisersoze/Library back to hidden.

Doing it manually works fine. Obviously, I want to create a script for this kind of thing.

\\

I am trying to automate this with Applescript. As a test, I am trying just to recover Safari settings.

So I want to now copy – ditto – replace, whatever, the following folder

/users/kaisersoze (deleted)/Library/Safari

into the new place

/users/kaisersoze/Library/Safari

Those parentheses – I suspect – is killing every attempt I make to duplicate the folder. I tried to embed shell commands with copy or ditto, but they all don’t work. I have been trying to do it by calling a shell script or telling Finder to “duplicate folder x to folder y with replacement”. I am not able to get it to work.

Running shell scripts to remove files folders from the new users folder works. Running the chown commands, as well as chflags commands, all work.

I have tried to set a variable, like

set punter to kaisersoze

Because ‘punter’ is the variable placeholder for the user, etc.

set duhLete to "/users/" & punter & space & "(deleted)/Library"

or this will not compile, it returns an error

set duhLete to "/users/" & punter & "\ \(deleted\)/Library"

Am I completely backward on this approach? My head is really starting to ache.

Model: MacBookRetina
Browser: Safari 537.36
Operating System: Mac OS X (10.8)

You may try with :

set punter to "kaisersoze"

set duhLete to "/users/" & punter & space & "(deleted)/Library"
--> "/users/kaisersoze (deleted)/Library"

or

set punter to "kaisersoze"

set duhLete to "/users/" & punter & " (deleted)/Library"
--> "/users/kaisersoze (deleted)/Library"

Yvan KOENIG (VALLAURIS, France) jeudi 22 janvier 2015 22:17:02

Thank you for the reply. Actually, I tried all those variations, first.

To check that my lines were being commented out, I did test dialogs to report back what the script believed the variable duhLete to be. In each case, it reports back correctly as the path that it is. It just doesn’t do anything when I send it to a shell script or use the Applescript commands I have tried thus far.

\\

I think I made my initial question too complicated. What I want to know is how to do I script the following:

I want to copy the following folder

/users/kaisersoze/ (deleted)/Library/Safari

to replace and overwrite the following folder

/users/kaisersoze/Library/Safari