Welcome to MacBoardz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Cop-y file to preference folder

 
   Macintosh computer (Home) -> Apple Scripts RSS
Next:  drugstore com affiliate program affiliated pharma..  
Author Message
Jack B. Pollack

External


Since: Dec 19, 2003
Posts: 39



(Msg. 1) Posted: Sun Aug 03, 2008 7:25 pm
Post subject: Cop-y file to preference folder
Archived from groups: alt>comp>lang>applescript (more info?)

Hi,

I'm trying to script the copy of a preference file that lives inside a
package in a disk image to the users preference folder. Both source &
destination folders need to be determined on the fly and can not be hard
coded. I'm fairly new to AppleScript, but though this would be easy (I have
now spent the entire day on this!).


Any help would be greatly appreciated.

 >> Stay informed about: Cop-y file to preference folder 
Back to top
Login to vote
Jolly Roger

External


Since: Sep 09, 2006
Posts: 1943



(Msg. 2) Posted: Sun Aug 03, 2008 7:25 pm
Post subject: Re: Cop-y file to preference folder [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article ,
"Jack B. Pollack" wrote:

> I'm trying to script the copy of a preference file that lives inside a
> package in a disk image to the users preference folder. Both source &
> destination folders need to be determined on the fly and can not be hard
> coded. I'm fairly new to AppleScript, but though this would be easy (I have
> now spent the entire day on this!).

Open the "Standard Additions" dictionary and look at the "path to"
command. That command will let you get the path to the preferences
folder for the current user.

It sounds like you are saying your script needs to calculate the path to
something in a package residing on a disk image. You'll have to explain
what information your script *does* know about the package or disk
image. To start with, what's the disk image name? What's the package
name? Is the script itself included on this disk image?

--
Note: Please send all responses to the relevant news group. If you
must contact me through e-mail, let me know when you send email to
this address so that your email doesn't get eaten by my SPAM filter.

JR

 >> Stay informed about: Cop-y file to preference folder 
Back to top
Login to vote
Jack B. Pollack

External


Since: Dec 19, 2003
Posts: 39



(Msg. 3) Posted: Sun Aug 03, 2008 8:03 pm
Post subject: Re: Cop-y file to preference folder [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Jolly Roger" wrote in message

> In article ,
> "Jack B. Pollack" wrote:
>
> > I'm trying to script the copy of a preference file that lives inside a
> > package in a disk image to the users preference folder. Both source &
> > destination folders need to be determined on the fly and can not be
hard
> > coded. I'm fairly new to AppleScript, but though this would be easy (I
have
> > now spent the entire day on this!).
>
> Open the "Standard Additions" dictionary and look at the "path to"
> command. That command will let you get the path to the preferences
> folder for the current user.
>
> It sounds like you are saying your script needs to calculate the path to
> something in a package residing on a disk image. You'll have to explain
> what information your script *does* know about the package or disk
> image. To start with, what's the disk image name? What's the package
> name? Is the script itself included on this disk image?
>
> --
> Note: Please send all responses to the relevant news group. If you
> must contact me through e-mail, let me know when you send email to
> this address so that your email doesn't get eaten by my SPAM filter.
>
> JR
 >> Stay informed about: Cop-y file to preference folder 
Back to top
Login to vote
Jolly Roger

External


Since: Sep 09, 2006
Posts: 1943



(Msg. 4) Posted: Sun Aug 03, 2008 8:03 pm
Post subject: Re: Cop-y file to preference folder [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article ,
"Jack B. Pollack" wrote:

(nothing)

Mistaken post?

--
Send responses to the relevant news group. E-mail sent to this address
may be devoured by my ravenous SPAM filter. Due to Google's refusal to
prevent spammers from posting messages, I often ignore posts from
Google. Use a real news client if you want me to see your posts.

JR
 >> Stay informed about: Cop-y file to preference folder 
Back to top
Login to vote
Jack B. Pollack

External


Since: Dec 19, 2003
Posts: 39



(Msg. 5) Posted: Sun Aug 03, 2008 8:09 pm
Post subject: Re: Cop-y file to preference folder [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Jolly Roger" wrote in message

> In article ,
> "Jack B. Pollack" wrote:
>
> > I'm trying to script the copy of a preference file that lives inside a
> > package in a disk image to the users preference folder. Both source &
> > destination folders need to be determined on the fly and can not be
hard
> > coded. I'm fairly new to AppleScript, but though this would be easy (I
have
> > now spent the entire day on this!).
>
> Open the "Standard Additions" dictionary and look at the "path to"
> command. That command will let you get the path to the preferences
> folder for the current user.
>
> It sounds like you are saying your script needs to calculate the path to
> something in a package residing on a disk image. You'll have to explain
> what information your script *does* know about the package or disk
> image. To start with, what's the disk image name? What's the package
> name? Is the script itself included on this disk image?
>
> --
> Note: Please send all responses to the relevant news group. If you
> must contact me through e-mail, let me know when you send email to
> this address so that your email doesn't get eaten by my SPAM filter.
>
> JR


Thanks for your post.

That is sort of what I have been playing with all day.

I have tries variations of setting source to path to me as text and
destination to path to preferences as text.
Then "copy file" or "duplicate" but have not been able to get the file over
there.

The disk image name is "Update Settings" and the package name is "Double
click me". I am saving the script as a "Application Bundle" and putting a
preconfigured preference file within that package.
 >> Stay informed about: Cop-y file to preference folder 
Back to top
Login to vote
Jolly Roger

External


Since: Sep 09, 2006
Posts: 1943



(Msg. 6) Posted: Sun Aug 03, 2008 8:09 pm
Post subject: Re: Cop-y file to preference folder [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article ,
"Jack B. Pollack" wrote:

> "Jolly Roger" wrote in message
>
> > In article ,
> > "Jack B. Pollack" wrote:
> >
> > > I'm trying to script the copy of a preference file that lives inside a
> > > package in a disk image to the users preference folder. Both source &
> > > destination folders need to be determined on the fly and can not be
> hard
> > > coded. I'm fairly new to AppleScript, but though this would be easy (I
> have
> > > now spent the entire day on this!).
> >
> > Open the "Standard Additions" dictionary and look at the "path to"
> > command. That command will let you get the path to the preferences
> > folder for the current user.
> >
> > It sounds like you are saying your script needs to calculate the path to
> > something in a package residing on a disk image. You'll have to explain
> > what information your script *does* know about the package or disk
> > image. To start with, what's the disk image name? What's the package
> > name? Is the script itself included on this disk image?
>
> Thanks for your post.
>
> That is sort of what I have been playing with all day.
>
> I have tries variations of setting source to path to me as text and
> destination to path to preferences as text.

That's the way I would go about it.

> Then "copy file" or "duplicate" but have not been able to get the file over
> there.

So what happens when you try?

In general, you'll allow others to better help you with scripting
problems if you tell them not only what you tried, but how it failed.

Also, if you will create a short, sample script that illustrates the
problem without any superfluous commands, and post that script here, it
would help a great deal.

--
Send responses to the relevant news group. E-mail sent to this address
may be devoured by my ravenous SPAM filter. Due to Google's refusal to
prevent spammers from posting messages, I often ignore posts from
Google. Use a real news client if you want me to see your posts.

JR
 >> Stay informed about: Cop-y file to preference folder 
Back to top
Login to vote
Jack B. Pollack

External


Since: Dec 19, 2003
Posts: 39



(Msg. 7) Posted: Sun Aug 03, 2008 8:27 pm
Post subject: Re: Cop-y file to preference folder [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Jolly Roger" wrote in message

> In article ,
> "Jack B. Pollack" wrote:
>
> (nothing)
>
> Mistaken post?
>
> --
> Send responses to the relevant news group. E-mail sent to this address
> may be devoured by my ravenous SPAM filter. Due to Google's refusal to
> prevent spammers from posting messages, I often ignore posts from
> Google. Use a real news client if you want me to see your posts.
>
> JR

Sorry, been playing with this all day. Very tired Smile
 >> Stay informed about: Cop-y file to preference folder 
Back to top
Login to vote
Jack B. Pollack

External


Since: Dec 19, 2003
Posts: 39



(Msg. 8) Posted: Sun Aug 03, 2008 8:49 pm
Post subject: Re: Cop-y file to preference folder [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

> > > > I'm trying to script the copy of a preference file that lives inside
a
> > > > package in a disk image to the users preference folder. Both source
&
> > > > destination folders need to be determined on the fly and can not be
> > hard
> > > > coded. I'm fairly new to AppleScript, but though this would be easy
(I
> > have
> > > > now spent the entire day on this!).
> > >
> > > Open the "Standard Additions" dictionary and look at the "path to"
> > > command. That command will let you get the path to the preferences
> > > folder for the current user.
> > >
> > > It sounds like you are saying your script needs to calculate the path
to
> > > something in a package residing on a disk image. You'll have to
explain
> > > what information your script *does* know about the package or disk
> > > image. To start with, what's the disk image name? What's the package
> > > name? Is the script itself included on this disk image?
> >
> > Thanks for your post.
> >
> > That is sort of what I have been playing with all day.
> >
> > I have tries variations of setting source to path to me as text and
> > destination to path to preferences as text.
>
> That's the way I would go about it.
>
> > Then "copy file" or "duplicate" but have not been able to get the file
over
> > there.
>
> So what happens when you try?
>
> In general, you'll allow others to better help you with scripting
> problems if you tell them not only what you tried, but how it failed.
>
> Also, if you will create a short, sample script that illustrates the
> problem without any superfluous commands, and post that script here, it
> would help a great deal.
>

This is the kind of stuff I 've been trying. Test file does exist on
desktop. No error, but file does not copy either.

set source to ((path to desktop folder as text) & "com.testfile.plist")
set destination to ((path to preferences folder as text) &
"com.testfile.plist")

tell application "Finder"
if not (exists document file source) then
duplicate file source to destination
end if
end tell
 >> Stay informed about: Cop-y file to preference folder 
Back to top
Login to vote
Jolly Roger

External


Since: Sep 09, 2006
Posts: 1943



(Msg. 9) Posted: Sun Aug 03, 2008 8:49 pm
Post subject: Re: Cop-y file to preference folder [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article ,
"Jack B. Pollack" wrote:

> set source to ((path to desktop folder as text) & "com.testfile.plist")

This is fine; though you don't need the outermost parenthesis.

> set destination to ((path to preferences folder as text) &
> "com.testfile.plist")

Again, no need for the outermost parenthesis.

As stated in the Standard Additions dictionary, it's "preferences" - not
"preferences folder". You do look at the dictionaries when authoring
your scripts, right??

Also, The Finder's "duplicate" command expects the destination to be a
folder rather than a file. I think the logic is that "duplicate"
implies the name will be the same; so there's no need to specify that.
So you'll want to change this to point to the preferences folder.

> tell application "Finder"
> if not (exists document file source) then

Don't you want to check to see if the file exists in the *destination*
(preferences)?

Also, I'd omit "document" - just "file" will do.

> duplicate file source to destination
> end if
> end tell

This works for me:

set source to (the path to desktop folder as text) & "com.testfile.plist"
set destination to (the path to preferences as text)

tell application "Finder"
if not (exists document file source) then
duplicate file source to destination
end if
end tell

--
Send responses to the relevant news group. E-mail sent to this address
may be devoured by my ravenous SPAM filter. Due to Google's refusal to
prevent spammers from posting messages, I often ignore posts from
Google. Use a real news client if you want me to see your posts.

JR
 >> Stay informed about: Cop-y file to preference folder 
Back to top
Login to vote
Jack B. Pollack

External


Since: Dec 19, 2003
Posts: 39



(Msg. 10) Posted: Sun Aug 03, 2008 9:44 pm
Post subject: Re: Cop-y file to preference folder [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Jolly Roger" wrote in message

> In article ,
> "Jack B. Pollack" wrote:
>
> > set source to ((path to desktop folder as text) & "com.testfile.plist")
>
> This is fine; though you don't need the outermost parenthesis.
>
> > set destination to ((path to preferences folder as text) &
> > "com.testfile.plist")
>
> Again, no need for the outermost parenthesis.
>
> As stated in the Standard Additions dictionary, it's "preferences" - not
> "preferences folder". You do look at the dictionaries when authoring
> your scripts, right??
>
> Also, The Finder's "duplicate" command expects the destination to be a
> folder rather than a file. I think the logic is that "duplicate"
> implies the name will be the same; so there's no need to specify that.
> So you'll want to change this to point to the preferences folder.
>
> > tell application "Finder"
> > if not (exists document file source) then
>
> Don't you want to check to see if the file exists in the *destination*
> (preferences)?
>
> Also, I'd omit "document" - just "file" will do.
>
> > duplicate file source to destination
> > end if
> > end tell
>
> This works for me:
>
> set source to (the path to desktop folder as text) & "com.testfile.plist"
> set destination to (the path to preferences as text)
>
> tell application "Finder"
> if not (exists document file source) then
> duplicate file source to destination
> end if
> end tell
>

When I run the above script I get an error:
Finder got an error. Handler can't handle object of this class.
 >> Stay informed about: Cop-y file to preference folder 
Back to top
Login to vote
Jolly Roger

External


Since: Sep 09, 2006
Posts: 1943



(Msg. 11) Posted: Sun Aug 03, 2008 9:44 pm
Post subject: Re: Cop-y file to preference folder [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article ,
"Jack B. Pollack" wrote:

> "Jolly Roger" wrote in message
>
> >
> > This works for me:
> >
> > set source to (the path to desktop folder as text) & "com.testfile.plist"
> > set destination to (the path to preferences as text)
> >
> > tell application "Finder"
> > if not (exists document file source) then
> > duplicate file source to destination
> > end if
> > end tell
>
> When I run the above script I get an error:
> Finder got an error. Handler can't handle object of this class.

On what line?

Did you check for line wraps introduced by the news server or your news
client?

--
Send responses to the relevant news group. E-mail sent to this address
may be devoured by my ravenous SPAM filter. Due to Google's refusal to
prevent spammers from posting messages, I often ignore posts from
Google. Use a real news client if you want me to see your posts.

JR
 >> Stay informed about: Cop-y file to preference folder 
Back to top
Login to vote
Jack B. Pollack

External


Since: Dec 19, 2003
Posts: 39



(Msg. 12) Posted: Sun Aug 03, 2008 9:54 pm
Post subject: Re: Cop-y file to preference folder [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Jolly Roger" wrote in message

> In article ,
> "Jack B. Pollack" wrote:
>
> > "Jolly Roger" wrote in message
> >
> > >
> > > This works for me:
> > >
> > > set source to (the path to desktop folder as text) &
"com.testfile.plist"
> > > set destination to (the path to preferences as text)
> > >
> > > tell application "Finder"
> > > if not (exists document file source) then
> > > duplicate file source to destination
> > > end if
> > > end tell
> >
> > When I run the above script I get an error:
> > Finder got an error. Handler can't handle object of this class.
>
> On what line?
>
> Did you check for line wraps introduced by the news server or your news
> client?
Line wraps are OK. Error is on the duplicate line.
 >> Stay informed about: Cop-y file to preference folder 
Back to top
Login to vote
Jolly Roger

External


Since: Sep 09, 2006
Posts: 1943



(Msg. 13) Posted: Sun Aug 03, 2008 11:46 pm
Post subject: Re: Cop-y file to preference folder [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article ,
"Jack B. Pollack" wrote:

> "Jolly Roger" wrote in message
>
> > In article ,
> > "Jack B. Pollack" wrote:
> >
> > > "Jolly Roger" wrote in message
> > >
> > > >
> > > > This works for me:
> > > >
> > > > set source to (the path to desktop folder as text) &
> "com.testfile.plist"
> > > > set destination to (the path to preferences as text)
> > > >
> > > > tell application "Finder"
> > > > if not (exists document file source) then
> > > > duplicate file source to destination
> > > > end if
> > > > end tell
> > >
> > > When I run the above script I get an error:
> > > Finder got an error. Handler can't handle object of this class.
> >
> > On what line?
> >
> > Did you check for line wraps introduced by the news server or your news
> > client?
>
> Line wraps are OK. Error is on the duplicate line.

That's peculiar. It runs fine here.

I'm running Mac OS X 10.5. What version are you running? Perhaps the
Finder has changed a bit.

--
Send responses to the relevant news group rather than to me, as
E-mail sent to this address may be devoured by my very hungry SPAM
filter. Due to Google's refusal to prevent spammers from posting
messages through their servers, I often ignore posts from Google
Groups. Use a real news client if you want me to see your posts.

JR
 >> Stay informed about: Cop-y file to preference folder 
Back to top
Login to vote
Jack B. Pollack

External


Since: Dec 19, 2003
Posts: 39



(Msg. 14) Posted: Mon Aug 04, 2008 9:21 am
Post subject: Re: Cop-y file to preference folder [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Jolly Roger" wrote in message

> In article ,
> "Jack B. Pollack" wrote:
>
> > "Jolly Roger" wrote in message
> >
> > > In article ,
> > > "Jack B. Pollack" wrote:
> > >
> > > > "Jolly Roger" wrote in message
> > > >
> > > > >
> > > > > This works for me:
> > > > >
> > > > > set source to (the path to desktop folder as text) &
> > "com.testfile.plist"
> > > > > set destination to (the path to preferences as text)
> > > > >
> > > > > tell application "Finder"
> > > > > if not (exists document file source) then
> > > > > duplicate file source to destination
> > > > > end if
> > > > > end tell
> > > >
> > > > When I run the above script I get an error:
> > > > Finder got an error. Handler can't handle object of this class.
> > >
> > > On what line?
> > >
> > > Did you check for line wraps introduced by the news server or your
news
> > > client?
> >
> > Line wraps are OK. Error is on the duplicate line.
>
> That's peculiar. It runs fine here.
>
> I'm running Mac OS X 10.5. What version are you running? Perhaps the
> Finder has changed a bit.

I'm using 10.4.11.
I got it working finally

set s_Path to (path to me as text) & "Contents:"
set d_Path to (the path to preferences as text)
set FileName to "com.testfile.plist"

tell application "Finder" to duplicate file FileName of folder s_Path to
folder d_Path with replacing


Thanks for your help
 >> Stay informed about: Cop-y file to preference folder 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
preference file - Hi, I wrote an applescript that listens with an idle loop for newly mounted ejectable drives to copy the contents to a target folder. So far the target folder is defined in the script. I am looking for a way to have a preference file where the target ...

[newbie Q] how to get the path of the folder of a file? - This is an embarrassingly simple question that I cannot solve nonetheless... :-( Say I've got a path to a file: HD:myFiles:theImportantFolder:theImportantFile How do I then get the path of the folder that contains that file? That is, how do I get...

folder alias & name string = file alias - Hi, starting with myFolderAlias and iterating over "list folder" (which returns Unicode text), how to best concatenate the two to a file alias? Ugly but works: set fileAlias to ((POSIX path of myFolderAlias) & fileName) as alias -- To...

using choose file to open same folder repeatedly - I have the following pick some files that I use to create an HTML page. set theInfo to (choose file with prompt "Pick the info text file..." of type {"TEXT"}) set theProfile to (choose file with prompt "Pick the Profile Image.....

Set initial folder for File Save dialog? - Hello, While my OS X machine is in the shop for repairs (third time this year for the iBook/800), I'm trying to plan an OS X Applescript that will prompt the user for a filename to use when saving a PDF file (which will be created by converting a PS fil...
   Macintosh computer (Home) -> Apple Scripts All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]