Editing Text in Multiple Files with Textwrangler through Automator/Applescript - applescript

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

Related

how to skip content block in wordpad

I writing a code in vb.net. The codes will create a .rtf (wordpad file format). in that code i'm not only write text but a picture as well. the problem is windows always ask content security everytime i add a picture (fyi, picture already exist in my computer) into that file.
this is the preview
i tried to find setting in windows and wordpad, but still got nothing
how can i skip this security warning?
thank you
Just to clarify, I'm seeing the same issue. RTF created by hand by myself, new text with a few URLs, and pasted images captured by Windows screenshot grabbing app.
Dir /r was showing no alternate stream, but I still got the annoying message box every time I open the file.
Turns out the blocked content were the images, they also won't get copied to the clipboard. Tried grabbing them again, and pasting them to Paint and back to the document, and now WordPad likes them.

Using applescript / automator to run illustrator batch process

Is there a way to get Automator or Applescript to run 'batch' processes in Adobe Illustrator?
I have a workflow that handles a number of steps - but the key one is to use Illustrator variable data sets to replace two embedded eps files (one of a symbol and one of some text) and a bit of text with a product code.
I'm basically running through this:
http://hypertransitory.com/blog/2014/05/27/use-adobe-illustrator-variable-data-xml/
Except I have some php spitting out the xml that illustrator requires to use for data.
So I have my xml, and if I run a batch process from within illustrator that works fine - trouble is I want to do this multiple times - and each time I want the files to save in the same location. I can get automator to run an action in illustrator, but I can't create an action to load in and run through the data sets from the xml, saving each one. The only way illustrator seems to let you use the variable data sets is via 'batch' - which means you have to provide it with the 'Destination' to export the files to every time (and you can't use it as a step in Automator).
I'm using Illustrator CC (so I believe that's referred to as illustrator 17 in applescript) and OSX 10.10 (if that's relevant)
I'm new to applescript and am busy learning the syntax - but I can't find anything that seems to indicate this is going to be possible!
You can use Illustrator-friendly scripting languages to "manually" change out the datasets within the Illustrator document and output the files into your manually-coded location. If you can find the Applescript commands to do this, you can use it, otherwise you can make a .jsx extendscript and trigger it with your Applescript.
There are also a couple of sets of Illustrator Automator actions, which may be of use to you. Ai Actions and AI Automator Action Pack, both of which are available on the Mac app store. Not as versatile as coding your own bespoke solution using AppleScript (which is how I'd probably approach the problem), but much easier to implement. For the sake of transparency, I'm the developer of the former.

"Revert" command in AppleScript on OS X Lion

I'm in the middle of putting together a script that manipulates an OmniGraffle document and saves the result of each progressive manipulation as a PNG. That's all working fine, but at the end of process, I want to close the file without saving the changes.
Naturally, I reached for the "revert" command. Except that "revert" doesn't appear to be a command on Lion. I tried "close saving no," but since it was autosaving as each manipulation was made, that didn't work.
Of course, I can simply leave the document open and manually revert it. Nevertheless....
Am I missing something? Is there truly no way to programmatically roll back changes made to a file using AppleScript on Lion?
Update: it appears to be worse than I expected — on a volume without permanent version storage, at least — after many manipulations with AppleScript, "Revert Document…" was no longer even available in the File menu.
I can only think of a workaround: since you're not interested in keeping those intermediate versions anyway, you could:
make a backup copy of the file prior to opening it in OmniGraffle
do your changes + PNG exports
close w/o saving
overwrite the file with the backup copy (and delete the backup)

AppleScript Editor record doesn't work

I have opened the AppleScript Editor and pressed Record button.
Then I run TextEdit, create a file and put some text there.
When I click the Stop button in AppleScript Editor, nothing was recorded, the window is blank.
What is the problem?
You can use the Record feature of the Automator to record the UI interaction steps needed to do the relevant workflow. Then you can then literally select and copy the recorded steps in automator and paste them into a new Applescript Editor window. This will give you applescript which may or may not work. You'll probably want/need to edit the resulting script, but at least it should help give an idea what is needed to achieve your workflow programatically. This method is usable regardless of whether or not the target application has an applescript dictionary or supports the AppleScript Editor Record button, as it is the interaction with the underlying UI elements which is recorded.
Steps:
Open Automator
Start a new "Workflow"
Start recording
Perform whatever steps you require with your app (in this case typing into textedit)
Stop recording
This will create a list of actions in Automator like:
Select all these and copy (CMD+c)
Open the Applescript Editor app
Paste (CMD+v). The result will be valid applescript to perform the actions you just recorded:
Note that as is generally the case with UI automation, the automator records steps exactly and the script plays them back exactly. This my not be exactly what you want - e.g. if a different application were active, the text could get typed in there instead. The generated applescript should be used as a guide to the final applescript.
The problem is that applications need to explicitly support AppleScript recording in order for it to work, but almost no applications actually do. Finder still supports it a bit, and maybe a couple other apps (BBEdit comes to mind), but for the most part, AppleScript recording has been pretty useless for quite some time.
Not all apps are recordable (in fact, only a small handful are). Recordablity is something each app needs to implement, and I guess TextEdit isn't recordable.

Writing a simple app to convert files to pdf

I want to create an application on a Mac to convert multiple files (txt, pdf, doc, html, etc) to a single pdf file that can be printed. The real point is that if you have 50 texts you don't have to open every single file and click command-p.
I'm not quite sure whether the best way to do this is by creating a full-fledged app or an automator plugin (or something else). If I remember correctly there's a filter in mac os's terminal that can convert files to pdf (but I forgot what it's called).
So would an automator plugin do this well, or shall I make an app for this? Can you provide me advantages for each answer?
I've done cocoa touch programming before so I can write objective-c quite well.
Use appscript, either as an action in an automator script or standalone. The advantage is that it is very simple and will take you a fraction of the time to write an app.
Here is something very close to what you want. It sets up a drop-folder and each file dragged onto it is printed (you can use multiple-select to get what you want). It uses Apple Works 6 which doesn't support the file-types that you want.
To modify it to use the Preview application instead you need to change the tell command in the script and then google the dictionary for Preview to check which verb to use for printing.

Resources