Copying the files from server to desktop

Hi,

I’m again stuck with something:

I have a folder on server with a sub folder of scripts and another sub folder containing PDF presets.

Every time I update the scripts/presets, I have to copy them in all the machines one by one, replacing the old ones.

I would like to achieve this using an AppleScript in the following way;
I’ll keep this AppleScript along with the sub folders on the server and when a user clicks on the script:

The scripts-folder will be copied on to his Desktop replacing the old one and;
the PDF Presets files needs to be copied to the location given below:
Macintosh HD:Library:Application Support:Adobe:Adobe PDF:Settings

I tried to achieve this, but failed:

tell application "Finder"
	set userName to short user name of (system info)
	set theLocation to (target of front window) as string
	
	-- Copies the scripts to Desktop
	copy (folder "General_Scripts" of folder theLocation) to desktop
	
	-- Copies the PDF Preset to the Preset folder
	set DestinationPresetFolder to alias (folder "Test" of folder "Adobe PDF" of folder "Adobe" of folder "Application Support" of folder Library of folder userName) as string
	
	copy (every file of folder "PDF_Presets" of theLocation) to DestinationPresetFolder
	
end tell

However, the script is copying the General Scripts folder to the desktop successfully, but the latter part and the replacement is still missing in the script.
Any ideas…

Hi there,

I am about to find my way. I tried editing the script like this:

tell application "Finder"
	set userName to short user name of (system info)
	set theLocation to (target of front window) as string
	
	-- Copies the scripts to Desktop
	duplicate (folder "General_Scripts" of folder theLocation) to desktop with replacing
	
	-- Copies the PDF Preset to the Preset folder
	duplicate (every file of folder "PDF_Presets" of folder theLocation) to folder "Settings" of folder "Adobe PDF" of folder "Adobe" of folder "Application Support" of folder "Library" of folder userName of folder "Users" of startup disk with replacing
	
end tell

This has resolved my problem. But I’m still worry about the destination path for the PDF presets. It seems to be too long.
Moreover, can anyone suggest me how to create shortcuts in a Dock using the script.

Hi,

try this


set userApplicationSupportFolder to path to application support folder from user domain as text
tell application "Finder"
	set theLocation to target of front window
	
	-- Copies the scripts to Desktop
	duplicate (folder "General_Scripts" of theLocation) to desktop with replacing
	
	-- Copies the PDF Preset to the Preset folder
	duplicate (every file of folder "PDF_Presets" of theLocation) to folder (userApplicationSupportFolder & "Adobe:Adobe PDF:Settings") with replacing
	
end tell


Thanks Stefan, It is working fine.

How about adding a shortcut in the dock for every file from the “General_Scripts” folder of desktop (that is just copied).

I know you are the one, who can help me out.

I found this link http://macscripter.net/viewtopic.php?id=13548
However, I’m unable to write a code based on this…

Any ideas on how to add items to dock…

I have tinkered with that, but it’s been a while, so I do not have a working solution at hand.
The script you linked to made my Mac unusable…

Some ‘reverse engineering’ is required. Start with some files & folders in your dock, then run this script:

set prefsFile to (((path to preferences from user domain) as text) & "com.apple.dock.plist") as alias as text
tell application "System Events"
	set dockRec to value of property list file prefsFile -- everything
	set others to |persistent-others| of dockRec -- files & folders
end tell

Others will contain the metadata for the files & folders in your dock, so you can work out what you need to add to that list.
(It’s actually a list of records, and the records contain records - easy to get lost)

I did have some links that should show you how to proceed:

Look for posts from Luther Fuller.

Actually none of the three coercions is needed, as text after user domain without parentheses is a parameter, not a coercion


set prefsFile to (path to preferences folder from user domain as text) & "com.apple.dock.plist"

That’s what you get when digging up old stuff.:confused:

Better safe than sorry. :wink:

Hello All,

Thanks for trying a solution, but how do I fit this in my script? I’m not a script writer. Please advise.

Unless you want to be sure that the file exists before opening it, you could use two lines:

set prefsFile to (path to preferences from user domain as text) & "com.apple.dock.plist"
prefsFile as alias -- throws error when file doesn't exist

A string as alias as string creates a nice one liner with the cost of only one extra coercion.

It’s very improbable that com.apple.dock.plist does not exist :wink:

True :slight_smile:

I should have explicitly said, that in this case you were right but in general it could be useful.

My request is still pending…

That must have been the case. I think I pulled code from a more general solution where the test was the sensible thing to do.

Please start a new thread with that request, and I’ll see what I can come up with.

Hey,

I’m trying to update my old script but can’t figure it out. I want to copy fonts from a folder in Active window to “user/library/fonts” folder.

My script is this, can someone please help me out:

set userApplicationSupportFolder to path to application support folder from user domain as text
tell application "Finder"
	set theLocation to target of front window
	
	-- Copies the scripts to Desktop
	duplicate (folder "General_Scripts" of theLocation) to desktop with replacing
	
	-- Copies the PDF Preset to the Preset folder
	duplicate (every file of folder "PDF_Presets" of theLocation) to folder (userApplicationSupportFolder & "Adobe:Adobe PDF:Settings") with replacing

	-- Copies the Fonts to the User Fonts folder
	set myPath to (path to home folder as text) & "Library:Fonts" as alias
	duplicate (every file of folder "Fonts_xyz" of theLocation) to folder (myPath) with replacing

end tell