Re: New to AS... What am I doing wrong?
Re: New to AS... What am I doing wrong?
- Subject: Re: New to AS... What am I doing wrong?
- From: Graff <email@hidden>
- Date: Wed, 10 Mar 2004 13:01:29 -0500
There's a lot of stuff you don't need in there. Basically it looks
like you want just a basic copy script. Here's an example:
----------
property templateFile : (path to desktop as text) &
"americanexpress.com/paperles.textClipping"
on main(filelist)
tell application "Finder"
set theLocation to container of item 1 of filelist
duplicate file templateFile to theLocation
end tell
end main
----------
To break it down for you, first it sets a property of the script which
is the location of the file you want to copy. It then starts the main
handler, which I assume is called by BigCat. I changed it to an open
handler when I was testing this script since I don't have BigCat. An
open handler would let you drag a file onto an applet saved by Script
Editor.
It then tells the finder to set "theLocation" to the enclosing folder
of one of the files that you used the CM on. Since they are probably
all in the same folder I felt it was safe to just pick one of them. It
then duplicates the file in "templateFile" to the folder set in
"theLocation". I need to put the keyword "file" in front of
"templateFile" because "templateFile" is actually text. Putting "file"
in front of it coerces it into a variable of type file. "theLocation"
is already of type folder so I don't need to coerce anything there.
I took out all the clipboard stuff because it didn't look like you
needed it. It can be added back in if you do.
-Ken
On Mar 10, 2004, at 12:06 PM, CP wrote:
Hey everyone, I read through these lists from time to time but have
never posted. I'm pretty new to AppleScript, but I understand some of
the fundamentals so far. I'm trying to modify a script that came with
the "BigCat" contextual menu plugin. The CM just lets you choose & run
one of the apple scripts located in a folder in the library.
So I'm trying to modify this script that copies the path of the
specified file or location to the clipboard. If you just select a
blank area of a window, it'll copy the directory path of that window.
So heres the original:
on main(filelist)
set s to ""
set ctitems to count of items in filelist
repeat with i from 1 to ctitems
set s to s & ((item i of filelist) as string)
if i < ctitems then
set s to s & ", "
end if
end repeat
set the clipboard to (s as string)
end main
And I'm trying to get it to copy a file from a specific location to the
location that the original script adds to the clipboard.
Like so:
on main(filelist)
set s to ""
set templateFile to ""
set ctitems to count of items in filelist
repeat with i from 1 to ctitems
set s to s & ((item i of filelist) as string)
if i < ctitems then
set s to s & ", "
end if
end repeat
set the clipboard to (s as string)
set templateFile to "Macintosh
HD:Users:cpruitt:Desktop:americanexpress.com/paperles.textClipping"
tell application "Finder"
activate
duplicate templateFile to (s as string) --"Macintosh
HD:Users:cpruitt:"
end tell
end main
It seems to still copy 's' to the clipboard, but wont copy the file to
that location. If I manually use a path (commented out) instead of a
variable it works fine. Anyone have any thoughts on what I need to
change to get it to work?
Thanks from the new guy...
- Cliff
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.