DT 3.0beta4 - update script

For DTPO you kindly created a script - Select All - for inserting line breaks in a dense block of text. I have copied/pasted the script into the DT3 scripts folder and put it the Format folder and am pleased to say it works as before.

I don’t have the know-how to modify the script slightly so despite my attempts i cannot.

Pre script the file name is: 4-04 Agreements to surrender and new procedures
After script, it is: Excerpt from - 4-04 Agreements to surrender and new procedures
(After script, the filename is in blue colour)

What I’d very much like and appreciate please is for the "Excerpt from - " to be at the end of the file name:

4-04 Agreements to surrender and new procedures - Excerpt from

The benefit to me of that modification is that the file can be sorted without having to be first renamed. (I’ll lnow it’s the scripted version because the filename is in blue.)

Thank you in anticipation,

You just need to swap the position of text you add on and the name. To do this, replace this code:

name:("Excerpt from - " & (name of content record) as string)

with this:

name:( (name of content record) & " - excerpt from" as string )

But PLEASE test this out before using!

Tested and works, thank you very much.

The only difference is that after running the script the filename is not in colour. How do I modify the scirpt code to get the colour.

After name: I deleted the ( and that has made a difference. I wonder if it could be a bug in DT? Having run the script a couple of times on the same original file, sometimes the ‘excerpt from’ is in black and sometimes in blue. I can live with the colour, it’s the sort order and not having to rename for the sort that’s more important.

Presumably I don’t have to stick with ‘-excerpt from’ ? I might change it to ‘update’.

DT has an option to show the filename in blue if it is a duplicate, which might be what you are seeing.

Yep, anything inside the quote marks. Just be sure to have an initial space or dash (e.g. " update" or “_update”) so you don’t get a run-on word (like “4-04 Agreements to surrender and new proceduresupdate”.

It’s not working for me. Using my test copy (which does work) I duplicated it to Select All copy 2. Then i changed the wording as above but got warning pop-up. i double-checked the spacing and made sure the font etc matched and colour black and saved. Running it i still get - excerpt from.

Unless it’s something simple that I’m not doing, I’ll leave it. I can for batch renames use the rename remove suffix if necessary.

If you uploaded the code here as text (not a screen shot), one of us could edit it. To format it like code in your message, just put ``` on the line before you paste the code, and put ``` on the line after the code. LIke this:

paste code here

paste code here

tell application id “DNtp”


set allText to selected text of think window 1

set newText to do shell script “echo " & (quoted form of allText) & " | sed $'s_[.?!”] _&\

_g; /^[.?!" ]*$/d;’ | sed G "

create record with {name:(name of content record) & " - excerpt from" as string ), type: txt , content :newText} in current group

on error

display alert “No text selected in a document.”

end try

end tell

ps - Please change ’ - excerpt from’ to ’ - update’, thank you

In all the time I’ve been using the script, I never thought of that. Just assumed it was in the script. Thank you. In which case no need for the scripted result to be in blue.

You were missing a parenthesis in the “create record” line. I fixed it and it now compiles correctly (although I didn’t run the script). So replace the “create record” line in your script with the following:

create record with {name:((name of content record) & " - update" as string), type:txt, content:newText} in current group

We’ll see if that works.

Yes, it does, thank you.

Presumably it’s ok for me to rename the script? Currently it’s Select All copy 2. Can i simply rename it to eg Update?

Sure. You might have to restart DT for it to see the new name,