help a newb paste to clipboard

I tried “set clipboard to _____” and “copy.” I even tried recording the action, which puts this:
«event aevtcopy» selection
in the script. When I run the script, I get an error that says:
Finder got an error: Selection doesn’t understand the «event aevtcopy» selection message.
I’m opening a folder (In the finder), selecting all folders within it and then Copying. I then I want to paste the clipboard info to a Word doc. Help? Thanks so much.

You don’t need to open the folder first and you don’t need to select those inner folders - in fact that’s considered rather messy scripting. Of the several ways of getting the names onto the clipboard this is a simple, standard kind of proceedure:

tell application "Finder"
    set target to folder "MY HARD DISK:myTargetFolder"
    set folderList to ""
    repeat with aFolder in target's folders
        set folderList to folderList & (info for aFolder)'s name & return
    end repeat
end tell

set the clipboard to folderList Instead of 'return’s you could separate the names with 'tab’s or with anything else you like.
That was the easy bit, but now for the bad news. Getting your script to paste into a Word document is quite possible but, frankly, is not for a ‘newbie’ because Word is not scriptable. Why not consider using a different Word Processor for these sort of tasks - ‘Tex-Edit Plus’ would be my first recommendation. Sorry!
Andreas

: You don’t need to open the folder first and you don’t need to
: select those inner folders - in fact that’s considered rather
: messy scripting. Of the several ways of getting the names onto
: the clipboard this is a simple, standard kind of proceedure:
: tell application “Finder”
: set target to folder “MY HARD
: DISK:myTargetFolder”
: set folderList to “”
: repeat with aFolder in target 's
: folders
: set folderList to folderList &
: (info for aFolder )'s name &
: return
: end repeat
: end tell
: set the clipboard to folderList
: Instead of 'return’s you could separate the names with 'tab’s or with
: anything else you like.

: That was the easy bit, but now for the bad news. Getting your
: script to paste into a Word document is quite possible but,
: frankly, is not for a ‘newbie’ because Word is not scriptable.
: Why not consider using a different Word Processor for these
: sort of tasks - ‘Tex-Edit Plus’ would be my first
: recommendation. Sorry!

: Andreas

Thanks a lot! Told ya I was a newb. . how about SimpleText as the destination word processor?

: how about SimpleText as the destination word processor?
Sorry, Dave - you want life to be too simple(text)! Same problem as with Word.
I would still encourage you to look at Tex-Edit Plus but, OK, you could try a little cheat You need Akua Sweets and Sigma’s additions’ in your Scripting Additions folder; there are other ways but this is simple and those two osaxes are free (and very useful).

tell application "Finder" to set process "Word"'s frontmost to true
pause for 2 with seconds timing
type text "v" holding down command

Oh, and make sure ‘Word’ is already running before you run this.
Andreas

:: Oh, and make sure ‘Word’ is already running before you run this.
You probably already know this. If you want your script to open ‘Word’ then use, say…

tell application "Finder" to open application file id "MSWD"

Using the ‘id’ gets the Finder to do the finding, saving you the bother of feeding in the full address.
Good luck. Let us know how you get on.
Andreas

: You probably already know this. If you want your script to open
: ‘Word’ then use, say…
: tell application “Finder” to open application fileid “MSWD” Using the ‘id’ gets
: the Finder to do the finding, saving you the bother of feeding
: in the full address.

: Good luck. Let us know how you get on.

: Andreas
Thanks for the help! I’m off to eat dinner now, but I’ll try later this evening. Again, thanks.

: That was the easy bit, but now for the bad news. Getting your
: script to paste into a Word document is quite possible but,
: frankly, is not for a ‘newbie’ because Word is not scriptable.
: Why not consider using a different Word Processor for these
: sort of tasks - ‘Tex-Edit Plus’ would be my first
: recommendation. Sorry!
: Andreas
I have found Word to be scriptable, or at least a little, and have a snippet of code that could be used to get the list of folders into a Word document. I tried this and it works.
The first line below would be your actual list from the finder not my made up one.

set TheList to {"Folder 1", "Folder 2", "Folder 3", "Folder n"}
tell application "Microsoft Word"
	activate
	make new document
	tell front document
		repeat with i from 1 to count of items in TheList
			make new paragraph at end with data (item i of TheList as text)
			set last character of last paragraph to last character of last paragraph & return
		end repeat --with i
	end tell
end tell --Word

Andrew Herzog

Well, Andrew, I confess that I didn’t know that any version of Word was scriptable. My version (5.1) has no ‘aete’ resource at all, so even ‘activate’ is double-Dutch, never mind ‘document’, ‘window’ or ‘pragraph’.
So, Dave, does your version of MSWD respond to, say, telling it to ‘activate’? If you have a later version than mine, as it appears that Andrew has, then you might be in business along the lines that Andrew suggests.
Andreas

Hey, Dave, I’ve just had a thought that may simplify life for you. If you don’t need elaborate Word Processing then you may be able to do everything you want in an application that you already have - “Scriptable Text Editor”. Use Andrew’s code and you’ll be in business tonight.
A small comment for you, Andrew, if you will forgive me being pernickety. I don’t think you need to insert returns; if an app understands the word ‘paragraph’ then it will surely insert a return before each one other than the first. All you need is:

repeat with i from 1 to count TheList's items
    make new paragraph at end with data (TheList's item i)
end repeat

Andreas

…and, Dave - if the idea of the “Scriptable Text Editor” appeals but you need to end up with a Word doc (say to pass to someone else) - just save in STE “as text” and then change the creator to “MSWD”. Very easy, but if you need help getting your script to do it all then just ask.
Andreas

: You probably already know this. If you want your script to open
: ‘Word’ then use, say…
: tell application “Finder” to open application file id “MSWD”
: Using the ‘id’ gets the Finder to do the finding,
: saving you the bother of feeding
: in the full address.

: Good luck. Let us know how you get on.

: Andreas
Alright, this is making me batty. Here is the script as it stands now:

tell application "Finder"
	set target to folder "Macintosh HD:Disney Interactive"
	set folderList to ""
	repeat with aFolder in target's folders
		set folderList to folderList & (info for aFolder)'s name & return
	end repeat
end tell

set the clipboard to folderList
tell application "Tex-Edit Plus"
	activate
	make new window
	paste
end tell

tell application "Finder"
	set target2 to folder "Macintosh HD:Harwich Center"
	set folderList2 to ""
	repeat with aFolder in target2's folders
		set folderLis2t to folderList2 & (info for aFolder)'s name & return
	end repeat
end tell
set the clipboard to folderList2

tell application "Tex-Edit Plus"
	activate
	paste
end tell

Works like a charm until I try to paste to the clipboard the 2nd time, and I get “error of type -619.” Here’s what I’m trying to (ultimately) do: I want to search through a large number of folders for other folders with names that meet certain criteria. The person for whom I’m writing this script isn’t too comp. savvy, and I want to require as little input from her as possible while the script runs.

I thought I first paste all the folder names, then sort out the ones I want . . .
. . . whose name contains variable
onto a second document. Then do so with the contents of the next folder, then the next, and so on. In effect, I’d be using the Tex Edit Pro doc as a temporary clipboard. This way I could avoid the user having to click away dialog boxes asking to save changes to files, etc.

Whew! If you can just point me to copying and pasting several times to that doc, I’d be forever grateful.

Dave

I’m a bit pushed for time right now, so can’t go off and run your code, but a quick glance through it showed the most horrific of errors - something really shocking! I don’t think scripting is for you! This is an exact copy of one of your lines. See anything?

set folderLis2t to folderList2 & (info for aFolder)'s name & return

I think that’s hilarious! Warped sense of humour they tell me.
Andreas

A typo is a shocking horrific error?.. it happens to the best of us.

: I’m a bit pushed for time right now, so can’t go off and run your
: code, but a quick glance through it showed the most horrific
: of errors - something really shocking! I don’t think scripting
: is for you! This is an exact copy of one of your lines. See
: anything? set folderLis2t to folderList2
: & (info for aFolder )'s name
: & return I think that’s hilarious!
: Warped sense of humour they tell me.

: Andreas

: I’m a bit pushed for time right now, so can’t go off and run your
: code, but a quick glance through it showed the most horrific
: of errors - something really shocking! I don’t think scripting
: is for you! This is an exact copy of one of your lines. See
: anything? set folderLis2t to folderList2
: & (info for aFolder )'s name
: & return I think that’s hilarious!
: Warped sense of humour they tell me.

: Andreas

Well, that sure built a new guy’s confidence. Thanks.

To be serious for two seconds you might have another problem. You probably know about apps having their own ‘private’ clipboards, which only get onto the system clipboard when you leave the app.
If it ain’t bust for you then…, but a safer place for that 2nd transfer (you know, the one where you put “folderLis2t” on the clipboard, eh?) might be:

tell application "Tex-Edit Plus"
    activate
    set the clipboard to folderList2
    paste
end tell

Andreas

To Synotic (and you too, Dave).
Hey, you didn’t really take me seriously did you? I tried as hard as I could to make it obvious that I was being totally flippant.
If typos were the worst mistakes I ever made I’d be Oh so happy! Don’t make me think that I have to be po-faced and serious all the time.
Andreas

: Hey, Dave, I’ve just had a thought that may simplify life for
: you. If you don’t need elaborate Word Processing then you may
: be able to do everything you want in an application that you
: already have - “Scriptable Text Editor”. Use Andrew’s code and
: you’ll be in business tonight.

: A small comment for you, Andrew, if you will forgive me being
: pernickety. I don’t think you need to insert returns; if an
: app understands the word ‘paragraph’ then it will surely
: insert a return before each one other than the first. All you
: need is: repeat with i from 1 to
: count TheList’s items
: make new paragraph at
: end with data (TheList’s item i
: )
: end repeat Andreas

Not necessarily on the Automatic returns. I’ve done quit a bit in Quark and have found out that the return is just the last character in a paragraph and that your last paragraph in a story will actually not have a return at its end.

And now, Dave, for some irony. No, not peculiar humour - irony. A thread started in order to get something onto the clipboard might just end up with the realisation that the clipboard might not be needed, might not be the best way of achieving the desired result.
We collect data in ‘a’ (listFolder), then put it into ‘b’ (clipboard) in order to put it into ‘c’ (Tex-Edit doc). Now the contents of the clipboard are exactly the same as the contents of ‘a’, so why mess around with ‘b’? Why not put the contents of ‘a’ directly into ‘c’? Cut out the middle man!
I won’t spoon-feed you the code you might use - I’m a firm believer that finding out - and finding out where to find out - are excellent ways to learn. A clue - obviously look through the Tex-Edit dictionary but then you may find it worthwhile to cast an eye over the AS Demo that comes with Tex-Edit. (I don’t mean by running it - I mean by opening it in the Editor and looking at the code.) Obviously if you get stuck just yell - but from what I’ve already seen of the code you write I don’t think you’ll get stuck. Bingo time is when you can get rid of all references to the clipboard in your code.
If after that is done you want an additional idea you might ask whether it really needs TWO trips to Tex-Edit to accomplish the job. I suggest you get to Bingo point first and then maybe consider this.
Sincerely hope this is useful to you. Waiting for the next instalment…
Andreas

: your last paragraph in a story will actually not have a return at its end 

Isn’t that exactly what I wrote?
it will surely insert a return before each one other than the first
I said before, not after
Andreas