Bbedit Applescript command

186 views
Skip to first unread message

Eric

unread,
Aug 16, 2023, 8:02:57 PM8/16/23
to BBEdit Talk
Hi,
For context I have n AS that changes the creator type of a text file using Tex-Edit Plus which is no longer useable in Monterey so that Indesign recognises it.
The line is
save window 1 in file ResultFile as string with creator «class TBB6» with unstyled formatting
Is there an equivalent in BBEdit ?

The script snippet is here
Various script steps preceding defining variables
————
(*Process the file for InDesign*)
tell application "Tex-Edit Plus"
activate
open file SourceFile
save window 1 in file ResultFile as string with creator «class TBB6» with unstyled formatting
close window 1 saving no
end tell
tell application "Finder"
activate
end tell
—————— 
Thanks.
Kind Regards
Eric

Fletcher Sandbeck

unread,
Aug 16, 2023, 9:59:47 PM8/16/23
to bbe...@googlegroups.com
System Events can change some metadata. After giving the appropriate permissions, this works to set a file to open with TextEdit rather than BBedit. 


tell application "System Events"

set default application of file "/Users/fletcher/Desktop/myfile.txt" to file "Smog:System:Applications:TextEdit.app:"

end tell


Presumably this would work to set the Creator Type but it's harder for me to test.

tell application "System Events"

set creator type of file "/Users/fletcher/Desktop/myfile.txt.txt" to «class TBB6»

end tell


Hope this helps,

[fletcher]

--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/3ce0d94f-6111-47d2-ba8c-b7cafff0cd51n%40googlegroups.com.

Eric

unread,
Aug 18, 2023, 12:21:55 AM8/18/23
to BBEdit Talk
Hi Fletcher,
Thanks for responding.
I think because I've been struggling to understand what's happening I've struggled to explain the problem. 
Assuming along the way that its just an app switch.
But not quite so.
Below is text messy but I've narrowed down the issue.
The presenting problem is simply that in one case Indesign opens the import tagged text dialog and responds. In the other it misses that's tagged text coming in.

So this Snippet transforms the text and works.

(*Process the file for InDesign*)

tell application "Tex-Edit Plus"

activate

open file SourceFile

save window 1 in file ResultFile as string with creator «class TBB6» with unstyled formatting

close window 1 saving no

end tell

tell application "Finder"

activate

end tell(*Process the file for InDesign*)

tell application "Tex-Edit Plus"

activate

open file SourceFile

save window 1 in file ResultFile as string with creator «class TBB6» with unstyled formatting

close window 1 saving no

end tell

tell application "Finder"

activate

end tell


Resultant text is
_______
<ASCII-MAC>
<Version:3.000000><FeatureSet:InDesign-Roman><ColorTable:=<Black:COLOR:CMYK:Process:0.000000,0.000000,0.000000,1.000000>
etc etc with paragraphs and line feeds seperating text blocks
___________

This Snippet using BBEdit

(*Process the file for InDesign*)

tell application "BBEdit"

activate

open file SourceFile

save text document 1 to file ResultFile

close window 1

end tell

tell application "Finder"

activate

end


Results in this text all before getting to ASCII-MAC and produces no line feeds
__________
{\rtf1\mac\ansicpg10000\uc1 \deff4\deflang1033\deflangfe1033{\upr{\fonttbl{\f0\fnil\fcharset256\fprq2{\*\panose 00020206030504050203}Times New Roman{\*\falt Times};}{\f4\fnil\fcharset256\fprq2{\*\panose 00020005000000000000}Times;}
and so on 
_________


What is the switch I need to get in there that resolves the raw text to the Tex-Edit processed one ?


Thank you if you got this far


Kind Regards
Eric


Eric

unread,
Aug 18, 2023, 1:10:09 AM8/18/23
to BBEdit Talk
Hi again,
A bit more.

I've stepped through the whole process and it is in this line that the necessary transformations done

save window 1 in file ResultFile as string with creator «class TBB6» with unstyled formatting


Commenting out each phrase after ResultFile fails until it's all there. The works.

Switching to BBedit starts with not compiling with the Creator Type phrase.
Cutting that out and seeing I can force the string complies but fails to execute.
"Can’t make file "xyz" of application "BBEdit" into type string.

So I'm back to square one.
How to reproduce that line in BBedit :(

Kind Regards
Eric

Eric

unread,
Aug 18, 2023, 1:15:57 AM8/18/23
to BBEdit Talk
Ok last thing.
If I simply drag the SourceFile onto the TexEdit app it opens correctly formatted.
Drag it onto BBedit it doesn't.
Anyone know why ?
Kind Regards
Eric

Rick Gordon

unread,
Aug 18, 2023, 2:11:19 AM8/18/23
to bbe...@googlegroups.com
I suspect that either:

* It is not a text file; Tex-Edit Plus also handles RTF, DOC, and
AppleWorks files.

* It is a text file, but the text encoding is not matching what you've
chosen in BBEdit.

Rick Gordon

--------

On August 17, 2023 at 11:06:59 PM [-0700], Eric wrote in an email
entitled "Re: Bbedit Applescript command":
> Ok last thing.
> If I simply drag the SourceFile onto the TexEdit app it opens
> correctly formatted.
> Drag it onto BBedit it doesn't.
> Anyone know why ?
> Kind Regards
> Eric
>
>
> On Friday, August 18, 2023 at 3:10:09 PM UTC+10 Eric wrote:
>
> Hi again,
> A bit more.
>
> I've stepped through the whole process and it is in this line that
> the necessary transformations done
>
> *save*/window/1 in/file/ResultFileas/string/with
> creator«/class/TBB6» *with* unstyled formatting
>
>
> Commenting out each phrase after ResultFile fails until it's all
> there. The works.
>
> Switching to BBedit starts with not compiling with the Creator
> Type phrase.
> Cutting that out and seeing I can force the string complies but
> fails to execute.
> "Can’t make file "xyz" of application "BBEdit" into type string.
>
> So I'm back to square one.
> How to reproduce that line in BBedit :(
>
> Kind Regards
> Eric
>
>
> On Friday, August 18, 2023 at 2:21:55 PM UTC+10 Eric wrote:
>
> Hi Fletcher,
> Thanks for responding.
> I think because I've been struggling to understand what's
> happening I've struggled to explain the problem.
> Assuming along the way that its just an app switch.
> But not quite so.
> Below is text messy but I've narrowed down the issue.
> The presenting problem is simply that in one case Indesign
> opens the import tagged text dialog and responds. In the other
> it misses that's tagged text coming in.
>
> So this Snippet transforms the text and works.
>
> (*Process the file for InDesign*)
>
> *tell* /application/"Tex-Edit Plus"
>
> *activate*
>
> *open*/file/SourceFile
>
> *save*/window/1 in/file/ResultFileas/string/with
> creator«/class/TBB6» *with* unstyled formatting
>
> *close*/window/1 saving/no/
>
> *end* *tell*
>
> *tell* /application/"Finder"
>
> *activate*
>
> *end* *tell*(*Process the file for InDesign*)
>
> *tell* /application/"Tex-Edit Plus"
>
> *activate*
>
> *open*/file/SourceFile
>
> *save*/window/1 in/file/ResultFileas/string/with
> creator«/class/TBB6» *with* unstyled formatting
>
> *close*/window/1 saving/no/
>
> *end* *tell*
>
> *tell* /application/"Finder"
>
> *activate*
>
> *end* *tell*
>
>
> Resultant text is
> _______
> <ASCII-MAC>
> <Version:3.000000><FeatureSet:InDesign-Roman><ColorTable:=<Black:COLOR:CMYK:Process:0.000000,0.000000,0.000000,1.000000>
> etc etc with paragraphs and line feeds seperating text blocks
> ___________
>
> This Snippet using BBEdit
>
> (*Process the file for InDesign*)
>
> *tell* /application/"BBEdit"
>
> *activate*
>
> *open*/file/SourceFile
>
> *save*/text document/1 to/file/ResultFile
>
> *close*/window/1
>
> *end* *tell*
>
> *tell* /application/"Finder"
>
> *activate*
>
> *end*
>
>
> Results in this text all before getting to ASCII-MAC and
> produces no line feeds
> __________
> {\rtf1\mac\ansicpg10000\uc1
> \deff4\deflang1033\deflangfe1033{\upr{\fonttbl{\f0\fnil\fcharset256\fprq2{\*\panose
> 00020206030504050203}Times New Roman{\*\falt
> Times};}{\f4\fnil\fcharset256\fprq2{\*\panose
> 00020005000000000000}Times;}
> and so on
> _________
>
>
> What is the switch I need to get in there that resolves the
> raw text to the Tex-Edit processed one ?
>
>
> Thank you if you got this far
>
>
> Kind Regards
> Eric
>
>
> On Thursday, August 17, 2023 at 11:59:47 AM UTC+10 Fletcher
> Sandbeck wrote:
>
> System Events can change some metadata. After giving the
> appropriate permissions, this works to set a file to open
> with TextEdit rather than BBedit.
>
> *
> *
>
> *tell* /application/"System Events"
>
> *set* default application*of*
> /file/"/Users/fletcher/Desktop/myfile.txt" *to*
> /file/"Smog:System:Applications:TextEdit.app:"
>
> *end**tell*
>
>
> Presumably this would work to set the Creator Type but
> it's harder for me to test.
>
> *tell* /application/ "System Events"
>
> *set* creator type*of*
> /file/"/Users/fletcher/Desktop/myfile.txt.txt" *to*
> «/class/TBB6»
>
> *end**tell*
>> <https://groups.google.com/d/msgid/bbedit/3ce0d94f-6111-47d2-ba8c-b7cafff0cd51n%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
> --
> This is the BBEdit Talk public discussion group. If you have a feature
> request or need technical support, please email
> "sup...@barebones.com" rather than posting here. Follow @bbedit on
> Twitter: <https://twitter.com/bbedit>
> ---
> You received this message because you are subscribed to the Google
> Groups "BBEdit Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to bbedit+un...@googlegroups.com
> <mailto:bbedit+un...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/bbedit/1ac722e0-350d-4532-8ded-053a4aaf4f26n%40googlegroups.com
> <https://groups.google.com/d/msgid/bbedit/1ac722e0-350d-4532-8ded-053a4aaf4f26n%40googlegroups.com?utm_medium=email&utm_source=footer>.

___________________________________________
RICK GORDON
EMERALD VALLEY GRAPHICS AND CONSULTING
___________________________________________
WWW: http://www.shelterpub.com

Eric Wright

unread,
Aug 18, 2023, 2:57:46 AM8/18/23
to bbe...@googlegroups.com
Hi Rick,

The file is generated as a XML export from FileMaker using an XSL Style Sheet that merges the FileMaker stat with a Word RTF file.

The output though has the extension txt.

When I open it straight up in TexEdit_Plus the line breaks are fine.

So from what you’re saying BBedit is handling it as text.

Is there a way to have Bbedit read it in and out again as rtf ?

Sadly I set all this up as far back as 2004 at least and now can’t remember what not was about the import to InDesign that needed the reprocessing through TexEdit-Plus or it didn’t but that’s how remained the files as I cycled through categories in FileMaker.

Thanks for the guidance I shall continue to trash around till I figure it out and retiree my current mac !

Kind Regards
Eric


--- You received this message because you are subscribed to a topic in the Google Groups "BBEdit Talk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bbedit/hzZWFDppL-8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bbedit+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/64DF0B7B.6040008%40rickgordon.com.

Eric Wright

unread,
Aug 23, 2023, 8:08:00 AM8/23/23
to bbe...@googlegroups.com
Hi Rick,

Thank you. That’;s certainly the case. When I open it in Word it opens as rtf ands the header of the file spells it out.

So BBedit is the wrong replacement for Tex-Edit.

I’ve tried using Word itdsel in the script with our success but when I open the file in Word and Save As text it asks to confirm the encoding then works.

Works meaning Indesign recognises it as tagged text and formats on placement,

Do you know anything of scripting Word ?

Kind Regards
Eric


> On 18 Aug 2023, at 4:11 pm, Rick Gordon <li...@rickgordon.com> wrote:
>
> --- You received this message because you are subscribed to a topic in the Google Groups "BBEdit Talk" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/bbedit/hzZWFDppL-8/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to bbedit+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/64DF0B7B.6040008%40rickgordon.com.

Reply all
Reply to author
Forward
0 new messages