I have read through a bunch of the posts and still not ending up where I need to. Any help would be great. Macro action or AppleScript welcomed (or anything else I have yet to learn). Thank you!
- Macro is triggered.
- An Excel file is created/saved in Folder A (local_tempPath).
- The file is edited with the necessary information.
- The file is then moved from File A to File B (local_finalPath).
The naming convention of the file is saved to variable (local_fileName) in the beginning of the macro and used throughout.
Here is a mock up of what the bare bones version looks like:
Move file.kmactions (1.2 KB)
Okay, that makes sense.
Please give me real-world file paths and a real-world file name, so I have something to test with locally.
If the paths are within the home folder you can abbreviate:
If you're using external drives please say so.
Also – does the destination folder exist in advance of the file being moved there?
The files are actually on a Google Drive (company wide access) but accessed through GDrive App's permissions to access GDrive folders via Finder.
And both folders will already exist.
And they would look something like this:
I can't test with Google Drive, because it no longer supports Mojave – but with your paths replicated on my system this works every time.
Download: Move a File to a New Directory v1.0.kmmacros (2.6 KB)
- Macros are always disabled when imported into the Keyboard Maestro Editor.
- The user must ensure the macro is enabled.
- The user must also ensure the macro's parent macro-group is enabled.
- macOS 10.14.6
- Keyboard Maestro v10.2
It worked! Actually, took some fixing, but it worked.
This is for anyone who might read and use this in the future -
The template files are saved as .xlsm (excel). The local_fileName variable doesn't actually name it with the .xlsm extension. But because the extension shows in google drive, and can not be avoided, the "Move" action needs to have the extension in it so it can pick up the file. It needs to be:
@ccstone Unless there is a more efficient way to handle this further up the macro.
Your example above shows the file name with the file extension:
I find it difficult to believe that Google Drive is showing file extensions on macOS when there are none.
Furthermore – paths are not mutable. If a file extension is required then there IS a file extension – whether you can see it or not.
macOS can play stupid games with file extensions:
People who turn this setting off are just asking to have problems.
Ah yes, you are correct on all parts.
Was the example I gave you but then realized the local_fileName doesn't actually have that. So I needed to add it to the end for the moving actions.
And as for turning off the "Show all filename extensions" would have been helpful on the web browser google drive (not on my desktop) but alas, it doesn't allow.
@ccstone I am running into an issue because of the extensions, wondering if you have a thought around it.
When a person receives the spreadsheet, they receive it as an XLSM. If there is no Excel macro enabled, the person gets an error in the sheet. The reason they are all XLSM is because I thought if they were all uniform, it would be easier to manipulate (as shown in the above post). But with this error coming up for the end user, my team wants me to find a way to leave the XLS files as is and the XLSM files as is.
All this to say, I see one option:
Some action (using Regex maybe - pull characters after the . (dot)) that will pull the file extension of the file and set it to local_extension, to be used in the Move action when moving local_fileName (dot) local_extension from temp folder to final folder.
Is there something different you could think of that would work cleanly?
UPDATE: I think I figured it out. Using Split Path, I can set the extension path to a variable early in the macro and then use it again later when moving the file.
Split Path is the simplest, easiest to use solution.