FileManagerLib, RegexAndStuffLib updates

I’ve released a couple of upgrades. FileManagerLib 2.3.2 now has commands for dealing with date properties, while RegexAndStuffLib 1.0.6 accepts lists of strings for its regex change and regex batch commands.

Download them here:

https://www.macosxautomation.com/applescript/apps/Script_Libs.html

Hey Shane

I’m having trouble connecting to your site? Dont want to spoil your Friday night and it might just be my telstra cable connection…

Your connection, I think. Fine here on Optus cable.

No problem here, on Friday MORNING!

Wishlist for FileManagerLib:

return file size for a given file reference

Thanks Shane, these libraries are great. Very useful.

I’m considering it. The issue is that it has to be calculated for anything other than flat files, which makes it potentially a bit slow. I suppose I could use the Finder approach with big items, and just make up a number :wink:.

I think I hit a bug in Filemanger.

Nevermind. It was a bug of my own

–> Filemanagerlib v. 2.3.4
–> Script Debugger 7.0.11 (7A110)
–> Mac OS 10.11.6 (15G22010)

I cant get a simple copy command to run get an error saying the file doesnt exist.

use theLib : script "FileManagerLib" version "2.3.2"
set rawFile to "~/Pictures/66/Capture/60161665_1/60161665_1-0002.CR2"
--added for testing only
set theFileOb to (parse object rawFile)
set rawPath to parent_folder_path of theFileOb & "/" & full_name of theFileOb as string
set destFolder to "/Users/riallen/Pictures/66/Capture/"
set articleNumber to "theNewName"
set theCopyCR2 to copy object rawPath new name (articleNumber & "-0000.CR2") as string to folder (quoted form of destFolder) as string

I can parse the object but cant copy the object using the rawPath or rawFile variables?

I’m not sure why you’re going the circuitous route to build the path, but quoted form is only used with do shell script. Take that out and try again.

Thanks Shane I was running a shell in another part of the script and then copy pasted into this section :grimacing:

When I do a paste tell on the ``regex searchcommand in the regexAndStuffLib the last item is using sentinal boolean```

Don’t know what that is, but I don’t see it anywhere in the dictionary and it doesn’t come up in a search and I did a paste tell on a bunch of other commands and it’s not there.

set result_Text_List to regex search text ¬
   search pattern text ¬
   match case boolean ¬
   dot matches all boolean ¬
   anchors match lines boolean ¬
   Unicode boundaries boolean ¬
   replace template text ¬
   capture groups Number_List ¬
   using sentinal boolean

From the dictionary:
FUNCTION SYNTAX

set theResult to regex search text ¬
     search pattern text ¬
     match case boolean ¬
     dot matches all boolean ¬
     anchors match lines boolean ¬
     Unicode boundaries boolean ¬
     replace template text ¬
     capture groups integer or list of integer

While we’re on the topic of regexAndStuffLib I’d really like to see sample scripts.

Kind of a RegEx power, for dummies!

You can read the description in the library’s code. In the end, I decided there’s so little point in not using it, I cut it from the documentation. Unfortunately there’s no way to remove it from a paste tell, short of removing it.

If you’re after RegEx examples, the Web is really your oyster. There are different flavors, which can complicate things a bit, but there are zillions of examples out there.

I see regular expressions as a Swiss army knife with 10,000 blades when all I need is a pen knife to do one or two things. So when ever I look for a way to do simple things that require something like RegEx (like returning every paragraph from text with containing x and y) it seems like there’s an enormously complicated bit programming I need to learn.

I was hoping I could use regexandstufflib to just learn what I need, and sample scripts would go a long way.

This brings to mind a statement made years ago by Jamie Zawinski, a programmer best known for his role in the creation of Netscape Navigator and other major software projects. He said:

Some people, when confronted with a problem, think “I know, I’ll use regular expressions.”

Now they have two problems.

His comment seems about right to me.

Stan C.

1 Like