[FILES] Move & Rename Screenshots to Screen Shots Folder

OK, so I have been working on a regex to strip the filename. While it works just fine in Regex buddy I get an error message when I try to use it in Keyboard Maestro. The regex is

^(./)([^/])$

What is wrong with this? I am running on a mac and I can see the filepath + filename being passed into the regex and it looks like this:

/Users/gary/Desktop/Screen Shot 2016-10-28 at 4.01.38 PM.png

To strip the first path components (before the basename) this should do: .*/

(Then you have the same value for TriggerValue as before 7.1.)

Edit:

In more detail:

  1. At the beginning of the macro, save %TriggerValue% to a variable, e.g. %Variable%triggerValue%
  2. Delete the first path components from the variable with the regex.
  3. Replace every further instance of %TriggerValue% with %Variable%triggerValue%

But if your only purpose is to have all screenshots go to a specific directory, it’s probably more convenient to use this macro. (With it you just set the destination folder for screenshots, instead of moving them around.)

Hey @odin,

Keyboard Maestro has you covered in the Get File Attribute action.

Amongst the many attributes are “File Name” and “Parent Path”.

To answer your original question – you haven't properly populated the variable you're applying the regex to.

Always test first with hard-coded strings you can control and verify.

Generic-Test 01.kmmacros (1.8 KB)

In the case of this macro the variable filePath will not be populated until you run the macro OR right-click on the Set Variable action and select “Try”.

-Chris

1 Like