Monday, February 19, 2018

#1 2015-01-19 09:06:19 am

masoodahmad
Member
Registered: 2013-05-10
Posts: 72

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:

Applescript:

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...

Last edited by masoodahmad (2015-01-19 09:24:09 am)

Offline

 

#2 2015-01-19 11:18:12 am

masoodahmad
Member
Registered: 2013-05-10
Posts: 72

Re: Copying the files from server to desktop

Hi there,

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

Applescript:

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.

Offline

 

#3 2015-01-19 12:56:33 pm

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11487
Website

Re: Copying the files from server to desktop

Hi,

try this

Applescript:


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


regards

Stefan

Offline

 

#4 2015-01-20 03:49:02 am

masoodahmad
Member
Registered: 2013-05-10
Posts: 72

Re: Copying the files from server to desktop

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...

Last edited by masoodahmad (2015-01-20 06:57:59 am)

Offline

 

#5 2015-01-21 02:33:25 am

masoodahmad
Member
Registered: 2013-05-10
Posts: 72

Re: Copying the files from server to desktop

Any ideas on how to add items to dock...

Offline

 

#6 2015-01-22 05:15:11 am

alastor933
Member
From:: Utrecht, NL
Registered: 2008-09-12
Posts: 544

Re: Copying the files from server to desktop

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:

Applescript:

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.

Offline

 

#7 2015-01-22 05:23:27 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11487
Website

Re: Copying the files from server to desktop

alastor933 wrote:

Applescript:

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


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

Applescript:


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


regards

Stefan

Offline

 

#8 2015-01-22 07:59:57 am

alastor933
Member
From:: Utrecht, NL
Registered: 2008-09-12
Posts: 544

Re: Copying the files from server to desktop

StefanK wrote:

Actually none of the three coercions is needed


That's what you get when digging up old stuff.:/

Offline

 

#9 2015-01-22 08:59:52 am

McUsrII
Member
Registered: 2012-11-21
Posts: 3046
Website

Re: Copying the files from server to desktop

alastor933 wrote:
StefanK wrote:

Actually none of the three coercions is needed


That's what you get when digging up old stuff.:/


Better safe than sorry. wink

Offline

 

#10 2015-01-23 02:28:01 am

masoodahmad
Member
Registered: 2013-05-10
Posts: 72

Re: Copying the files from server to desktop

Hello All,

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

Offline

 

#11 2015-01-23 02:51:05 am

DJ Bazzie Wazzie
Member
From:: the Netherlands
Registered: 2004-10-20
Posts: 2730
Website

Re: Copying the files from server to desktop

StefanK wrote:
alastor933 wrote:

Applescript:

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


Actually none of the three coercions is needed...


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

Applescript:

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.

Offline

 

#12 2015-01-23 03:09:21 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11487
Website

Re: Copying the files from server to desktop

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


regards

Stefan

Offline

 

#13 2015-01-23 03:42:46 am

DJ Bazzie Wazzie
Member
From:: the Netherlands
Registered: 2004-10-20
Posts: 2730
Website

Re: Copying the files from server to desktop

StefanK wrote:

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


True smile

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

Offline

 

#14 2015-01-23 04:15:30 am

masoodahmad
Member
Registered: 2013-05-10
Posts: 72

Re: Copying the files from server to desktop

My request is still pending...

Offline

 

#15 2015-01-24 06:28:10 am

alastor933
Member
From:: Utrecht, NL
Registered: 2008-09-12
Posts: 544

Re: Copying the files from server to desktop

DJ Bazzie Wazzie wrote:

Unless you want to be sure that the file exists before opening it


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.

masoodahmad wrote:

My request is still pending...


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

Offline

 

#16 2018-02-13 08:05:45 am

masoodahmad
Member
Registered: 2013-05-10
Posts: 72

Re: Copying the files from server to desktop

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:

Applescript:

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

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)