Fwd: open for access command
Fwd: open for access command
- Subject: Fwd: open for access command
- From: Yvan KOENIG via AppleScript-Users <email@hidden>
- Date: Mon, 11 May 2020 09:18:24 +0200
> Le 10 mai 2020 à 21:57, le0car--- via AppleScript-Users
> <email@hidden
> <mailto:email@hidden>> a écrit :
>
> It is helpful with my work, for me to be able to see, at once, the top
> portions of a series of documents, documents that I am always editing up. I
> have written a script for the purpose (outline of it below). The script
> works, yet it opens and shuts a startling number of document windows for its
> function, rather disturbing to look at.
>
> I'd hopes of improving matters, by using using open for access command,
> instead of open. Sought advantage that that command would circumvent need of
> opening and shutting all the document windows, thought too (but not sure)
> that TextEdit application would not even need to launch. I have written a
> working draft of such script, that is, using open for access, followed by
> read command (i.e. [...where f is a file reference] "open for access f",
> then, "read f" ). While my draft works, it's of no us to me as the return is
> both internal data of the file along with the paragraphs of text the document
> contains (in other words, a mess). Wish I knew command's parameter for
> returning only the document's paragraphs without the internal data (if there
> is one), or else wish I know a way to strip the internal data away from the
> combined internal data and document's paragraphs (but similarly, doubt there
> is such way). Any ideas I'd appreciate. PS potential respondents, I'm not at
> computer every day, s
> o shall be probably several days with reply
>
>
> here is portion of my script, as it is currently.
> my variable "L" is set to a list of file references; these are the files in a
> particular folder, the files that I want the script to work on. I use a
> repeat construction, in conjunction with "rest of" to have the script act on
> all these files one at a time. My variable "t" starts out set to empty
> string, at the script's conclusion, it becomes the content that I wanted,
> and, then, assigned to the clipboard, I can paste the content anywhere I
> want:
>
> set t to ""
>
> tell application "Finder"
> set f to first item of L
> tell application "TextEdit"
> set ff to f as alias
> open ff
> paragraphs 1 thru 4 of text of front document & return & return
> set t to t & result
> close front document
> end tell
> end tell
> set the clipboard to t
If the documents are text ones you may use:
set t to ""
set L to choose file of type {"txt"} with multiple selections allowed
repeat with ff in L
set someText to read ff as «class utf8»
set myText to my recolle(paragraphs 1 thru 4 of someText, return) &
return & return
set t to t & myText
end repeat
set the clipboard to t
#=====
on recolle(L, d)
local oTIDs, t
set {oTIDs, AppleScript's text item delimiters} to {AppleScript's text
item delimiters, d}
set t to L as text
set AppleScript's text item delimiters to oTIDs
return t
end recolle
#=====
We aren't forced to use "open for access" to ro that.
If the files are rtf ones you would use ASObjC
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) lundi 11
mai 2020 09:17:05
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden