![]() I should probably add a snippet of my AppleScript so far. I suppose it's either: how to insert a comma at the end of lines without one? Or.how do I remove the very first character of a line in TextWrangler, using AppleScript / grep syntax? This workaround changes the subject line of my post. I realize I need to insert \ to get grep commands to work in AppleScript but evidently I can't get the correct syntax in AppleScript to remove that very first character, a comma. replacing with nothing.īut.I can't get that same grep command to run in AppleScript. In TextWrangler I can remove that comma with a search for ^. However, even if this last little "trick" works I'm still left with a single comma at the very beginning of the string. Then I end up with several sets of double commas, but one more search for, replacing with, fixes that. I can do a find/replace for all line breaks, replacing the breaks with commas. I should add that I already have a "workaround" that may be satisfactory. So my original goal was to simply add commas to the end of any lines that don't have one then removing the line breaks. those three long lines do not have commas at the end and ultimately everything needs to be comma separated. But for the few lines that do not end with commas, how can I do a replacement that is essentially: "for any lines that do not end with a comma - insert a comma"?Īs an example, let's say I'm left with a text doc that looks like this:ĮE8A8457,EE8A8466,EE8A8464,EE8A8462,EE8A8459,EE8A8457ĮE8A8842,EE8A8861,EE8A8859,EE8A8857,EE8A8855,EE8A8852,EE8A8850,EE8A8848,EE8A8842 Most of those lines have commas as the end, which I want to keep. ![]() In that regard this is really more of a TextWrangler, grep question than it is an AppleScript question, but I know this a solid pool of knowledge and someone here problems knows this answer.Ĭurrently, when I run my AppleScript I'm left with multiple lines of filenames. So far I have been running multiple find/replace searches in TextWrangler to clean up the text for my needs then I found out that I could consolidate several individual searches into a single AppleScript and be done with one click. The data that is returned gets dumped into a text document on my Desktop but I need to process this text a little further so that eventually I can paste a simple string of filenames, separated by commas, into Lightroom when I perform a search for filenames. Tyrannosaurus Regex: Markdown for newLISPĬreate a free website or blog at 'm running an exiftool command in Terminal to generate a list of photoshop files with all their respective layer names.A newLISP CGI web page in 10 easy steps.Functions That Use and the Functions That Get Used….Two (or more) challenges for the weekend.Process Finder Selection: the return of AppleScript (for a few seconds at least).newLISP at Wikibooks: volunteers wanted.To make it do something more useful, just insert more code: (dolist (file-name (2 (main-args))) 2īy the way, BBEdit/TextWrangler can run Unix filters on the current selection only, not just the whole file. So this script processes argument 2, the temporary version of your current document that BBEdit creates.Īs it stands, this script simply replaces each line of the current window with itself. argument 2: path to BBEdit’s temporary copy of the document. ![]() Notice the 2 in (2 (main-args)): this extracts the name of the file from the list of arguments that BBEdit passes to newLISP. Store your scripts in the ~/Library/Application Support/BBEdit/Unix Support/Unix Filters/ folder.Ī basic script looks like this: #!/usr/bin/newlisp If you’re using BBEdit or TextWrangler on MacOS X, it’s easy to write newLISP scripts that process text windows.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |