I would like to concatenate multiple text files with various extensions (.log, .log.1, .log.2, etc.) into a single file called -concatenated..
I have created this Automator service workflow which doesn't work:
failed Automator Service Workflow attempt
It only text text from the first items in my test (first item is a .log file, while the next one is a .1)
I can't figure out how to put the name and extension of the first file selected into a variable.
I am on macOS Big Sur 11.1, in case it is relevant.
It does not have to be automator but I would like something I can do quickly from within finder, either using the contextual menu or using a couple of key strokes (using Alfred for example).
Related
I'm looking for a solution to be able to select a text on an app(Figma) and then reverse it then store reverse version to the clipboard.
I used BetterTouchBar app for saving selected text but I can't do anything with it.
How can I do that with or without BetterTouchbar App.
Thanks a lot.
Create an Automator Quick Action1, setting Workflow receives current text in any application and add a Run AppleScript action, adding the following line of example AppleScript code where is says: (* Your script goes here *)
set the clipboard to the (reverse of characters of item 1 of input) as text
Save the Quick Action as e.g.: Reverse Selected Text To Clipboard
It's now available from the Services menu in any application, e.g. TextEdit > Services, or the Services menu on the Context menu (right-click menu).
You can also assign a keyboard shortcut in: System Preferences > Keyboard > Shortcuts > Services
1 In versions of macOS prior to Mojave a Quick Action is called a Service.
Note: The example AppleScript code is just that and does not contain any error handling as may be appropriate. The onus is upon the used to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors.
I am trying to write an Automator script, that replaces a given text by some other text. I followed the steps in
Editing text in Automator
which are the same as given by a bunch of blog posts covering this topic and may vary with regards to the language the script is written in. I tried with AppleScript and with bash.
My (reduced example) bash script is:
echo hello
I have selected the option "Output replaces selected text".
I tried the script when selecting text in Xcode, TextEdit and another app. The text is not replaced (it remains the same). The script is executed - as I tested via say hello inside of the script. Also I followed the setup of:
http://www.kevincallahan.org/software/services.html
to make sure my script is enabled in "System Preferences -> Keyboard -> Shortcuts -> Services -> [√] myService", because this tool used to work on my machine and it should have the same requirements for replacing text inside a TextView like the script I am going to write. Also I read the answer:
Automator not working inside xcode
from which I could not deduct, what "give xcode access to be able to modify accessibility settings" means. I am running macOS 10.13.4.
I finally figured something out. After creating a copy of the script in the file system, the copy worked. The only difference was the name. Indeed, if I renamed the original script, it worked. The name was "resolveConflicts". I have no app in my PATH with the same name. The only place I used the same name was inside SourceTree -> Preferences -> Custom Actions. Renaming the action in SourceTree did not allow me to successfully run the script with the name "resolveConflicts". In the end I could not figure out, with which name the scripts collided. I also checked /System/Library/Services and /System/Services. No scripts with same name existed there. I sticked with a different name.
I have an AppleScript source with this code:
«event coreslct» (last row of table X of document Y)
insert rows selection position below number of rows Z
The double angle brackets mean, the enclosed words are raw format or event code.
So my question is: what is the command of event code event coreslct...
The «event coreslct» as used in your example is specific to Microsoft Excel, and loosely translates to "select the cells concerned", or simply "select". To determine precisely what the definition of the command is you can perhaps try the instructions below:
According to Microsoft's KB:
To use the program-specific capabilities of Excel for Mac with
AppleScript, open and examine the AppleScript dictionary that is
supplied with Excel for Mac.
To use the Script Editor open the dictionary in Excel for Mac, follow
these steps:
1. Start the Script Editor. To do this, follow these steps:
a. Open your hard disk.
b. Open the Applications folder.
c. Open the AppleScript folder. For the Apple OS versions
earlier than OSX, open the Apple Extras folder, and then open
the AppleScript folder.
d. Double-click Script Editor.
2. On the File Menu, click Open Dictionary.
3. In the Open Dictionary dialog box, select Microsoft Excel
(Application) in the Name list, and then click Open.
In the window that appears, you can select an object or a class to
view its description. You can also click the bold suite names to view
an whole suite at one time. You can use the descriptions in this
window to create scripts in the Script Editor to control Excel for
Mac.
The versions of Excel for Mac listed at the beginning of this article
support a very large number of events. For a complete list, follow the
instructions in this article to open Excel for Mac in the AppleScript
Script Editor.
I don't have access to the Applescript dictionary mentioned above, however, it was ported to Python at some point, and you can view a complete set of commands here.
It's the select command of Microsoft Word. Wrap around a tell "Microsoft Word" block around it and it will be corrected using the application's dictionary.
I currently have an Automator workflow that uses Textwrangler to trim text files down for me.
These files are often full of the same bits of code and spaces, so I made a workflow where I click the Automator action which grabs all the text files in a folder, then uses a Dispense Items Incrementally action to pass them through Automator, where an Applescript runs multiple find/replace queries on each file, before saving and repeating.
All this time, I sit there while the files open, are edited and then closed & saved.
Is there not a way to do this without opening the files themselves? Could I not just tell Textwrangler (using some Applescript command) to grab that folder's text files, mess around with them in the background, and then save them?
The problem with opening them all up on your screen is it increases the chance of some error intefering with the workflow - quite often the workflow encounters some error and so I have to run it again.
(E.g. the way Automator might reduce jpeg picture size in the background is ideal.)
Thanks - happy to take any suggestions!
Tardy
I have custom Alfred workflow to File Filter some folders of my choice. I have two actions - to browse with Alfred, and, with CMD modifier, to open in Sublime.
I want to have an action where I may choose which program I want to open it in. I use 2-3 programs for basic editing, so I want to be able to select one of these.
Workflow would be:
start my workflow
enter few chars to find file
select a file with CMD
choose editor of choice from the list
How to implement the last thing? In other words, how to implement incremental actions e.g. "do this with this and then this".
There're two ways to do it.
Because you can choose which application will be used to open the file instead of the default one. A simple idea is using different keyword for each application. e.g. vim [file-name] for vim while sublime [file-name] for sublime.
Another way is using Run Script instead of Open File. An Apple script or Bash script can get the result in File Filter and open different application as you wish.