Re: [textsoap] How to pass a file in AppleScript?

37 views
Skip to first unread message

Mark Munz

unread,
Jul 5, 2023, 12:26:04 PM7/5/23
to text...@googlegroups.com
Apologies for not getting back sooner. The cleanFile command example seems to be missing from the docs. Not sure what happened. You can look at the Scripting Dictionary in AppleScript Editor to get a list of the commands. But this demonstrates how you would use it. You need to specify a file, usually a path to that file.

tell application "textsoapAgent"

set myfile to "/Users/myusername/test1.txt"

cleanFile myfile with "Uppercase"

end tell




On Thu, Jun 29, 2023 at 1:24 PM Ben Crist <benjami...@gmail.com> wrote:
Hello! Love this software and am looking to involve it in automation to help my team. I have Keyboard Maestro watching a folder for new text files, and I would like to pass them silently to TextSoap for processing with a custom filter.

I am asking about the mechanics of Keyboard Maestro on its forum, but what I need help with are how to specify an incoming file in an AppleScript that invokes TextSoap. I am using the script from documentation. "Transcript Cleaner" is my customer filter in TextSoap v9.

tell application "textsoapAgent"
     cleanFile with "Transcript Cleaner"
end tell

--
You received this message because you are subscribed to the Google Groups "TextSoap" group.
To unsubscribe from this group and stop receiving emails from it, send an email to textsoap+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/textsoap/f5313dd8-5330-49eb-b4bf-e7907b652220n%40googlegroups.com.


--
Mark Munz
unmarked software
https://textsoap.com/

Mark Munz

unread,
Jul 5, 2023, 7:15:55 PM7/5/23
to text...@googlegroups.com
I'm running the beta version, which has updated its "file cleaning" behavior. There is a bug in textsoapAgent 9.2.5b4 where the results of "cleanFile" command are placed in a subfolder "results" at the same location. However, starting with 9.2.5b5, there will be a new "destFolder" parameter in the command to specify a folder for the results. And the default is to replace the existing file (if no destFolder is specified or is "").

Julien Dion (Universus)

unread,
Nov 11, 2023, 9:03:29 PM11/11/23
to TextSoap
I don't know about Keyboard Maestro, but I'd like to do something similar with a Folder Action from Apple.
Since I don't know how will be named the file that will be added, what should I put (instead of the path to 1 file)?, on the line of the :

set myfile to "/Users/myusername/test1.txt"

+ If I want it to run on every file when it's added, (sometime multiple at the time), how should I proceed ?

+ I'm also looking into a way to have it use a different cleaner depending on the file name. I guess this is out of subject for this forum. But just in case, would anyone know how / or where could I find out ?

(I'm not an experienced dev. but I'm learning the basics 🤓 )

Thanks !

Mark Munz

unread,
Nov 16, 2023, 11:49:39 AM11/16/23
to text...@googlegroups.com
You can create an Automator Folder Action.

CleanShot 2023-11-16 at 08.41.52.jpg

CleanShot 2023-11-16 at 08.41.33.jpg

This will apply the cleaner "Uppercase" to any file dropped in the specified folder (in the above example, "MyFolderAction")

I believe there is still a way to do it with just AppleScript as well (ie. making it a droplet script), but I haven't researched that in quite a while.
The basic premise is the same, walk through the list of paths and run the cleanFile command on each path.

Hmm, in thinking about it, I don't know if the cleanFile will handle a list of files (ie you drop a whole group of files) or not. I think it currently processes a single file at a time.
It's been a while since I've dug into the AppleScript command handling, so some of this is on memory.

Mark

Reply all
Reply to author
Forward
0 new messages