The way your macro is currently set up, it's trying to copy every file in the Google Drive folder whenever a new file is added to it, which explains why you're getting the "destination already exists" error. If you only want to copy the newly added file, you need to use the %TriggerValue% token, and you don't need the For Each action:
Hi @gglick,
thank you very much for your quick reply.
After replicating your macro, i got this error:
File action failed because source is not a full path (null) in Macro ... while exectuing Copy File "%TriggerValue%".
No problem. I'm guessing you tested the macro by running it from the editor, rather than by actually adding a file? The %TriggerValue% token won't work with a folder trigger unless a file has actually been added to the folder in question, so try adding a test file to the folder and seeing if that doesn't do the trick.
I’m sorry for reviving an age old thread but I’m looking to do a similar thing, but only including files that have a specific extension (.mp3).
Basically when working on Pro Tools I bounce my mixes to .wav + .mp3. Both files go to the session’s “Bounced Files” directory by default. But I’d like to automatically move the newly created .mp3 file (NOT the associated .wav) to my Google Drive as I have no use for it on my hard drive, it’s just for sharing with my clients.
I always immediately delete the .mp3s after sharing them to my Google Drive folder on my desktop app. Is there any way to automatically move newly created .mp3 files within a specific folder to Google Drive ? Thanks !
In an ideal world here’s what I’d love do be able to do:
Each time a new .mp3 file is created in FOLDER 1 (HDD), it is copied to FOLDER 2 (Google Drive).
Once copied, the original .mp3 file is moved to the Trash.
Optional: my main Pro Tools folder (where all my PT projects are first created) has subfolders for each different artist/client. Those subfolders each have their own subfolders for album title, and sub-sub folders for track title which contains the Pro Tools session itself.
My question regarding the above is this: could there be a way to use KM so that each time a new .mp3 file is created in FOLDER 1 (example: SONG 1 MIX 2.mp3), a copy of it is sent to Google Drive DIRECTLY inside the folder named SONG 1?
In other words is KM able to recognize that “SONG 1.mp3” contains the same name as one of my Google Drive folders and sends the .mp3 file directly to the corresponding folder ?
As a start, if you want to delete the file from the original location there are two ways i) instead of copying the file, move the file using the "Move or Rename a File" action or ii) after moving the file use either the "Trash a File" or "Delete a File" action (note: they differ in that the first moves the file to trash, the second permanently deletes the file).
As to sending a file to the corresponding folder, it is possible using Regular Expressions (see Wiki Link for Regular Expressions ), provided you use a constant naming structure. For example, you can use a regular expression to select the first word in a string of characters, etc.
If you can provide a clearer (at least to me) of i) the song naming format and ii) the folder naming format, I can provide more help. For this to work the naming conventions for both the song and folder must follow a consistent pattern!
The Finder window on the left is my main HDD drive which contains the song folders in which all files pertaining to the Pro Tools session are located, the one on the right is the corresponding Google Drive main folder which contains song folders which contain only the .mp3 bounced mixes.
Both folders are named “ROSA ROSA - ALBUM 2025” and contain the same sub-folders each with its corresponding song title. The .mp3 files themselves are named, for example with the song called “Mayfield”: MAYFIELD MIX V#.mp3
As of now I still haven’t been able to copy a file from the main HDD to the Google Drive folder, regardless of sub folders etc…I may have made a mistake in my macro, should I first do:
I might add that I’ve already tried to execute the following actions with Automator, but it failed miserably because of Spotlight index issues. My source folder is in an ExFAT external SSD.
I am walking into a meeting but will respond later assuming all the other helpful people here don’t respond first!
In the meantime:
The if statement comes first so that only MP3 files are moved. Place your actions where the green comment box is.
Where have you defined the destination folder, ~/DestFOLDER in the above? Is there more to your macro and, if yes, post it. If you have not defined the destination folder, then that is the reason it is failing
Your macro is triggered by an addition the Google Drive folder, and then copies that newly-added item to your Desktop. That's the other way round to your text.
Make sure you're doing the right test!
Note that KM's "Folder" trigger doesn't work for additions to subfolders -- and it looks like that's what you want to do. If that's the case you should really look to Hazel instead.
I gave Hazel a try, it looks nice and easy to use but haven’t really got deep into it yet. For now I’ve managed to put all of my Pro Tools « Bounced Files » folders as sources and all of their respective Google Drive counterparts as destinations, and everything seems to be working fine.
However I still have to manually prep all of those source folders before hand (and there are dozens if not hundreds of them). If there was a way for me to do the following: each time a new mp3 file is created anywhere in the parent folder, it is automatically moved into Google Drive’s subfolder if the name matches (if my mp3 is called « Song 1 MIX 2.mp3 », it would be moved to the Google Drive subfolder called « Song 1 » and so on…).
I’m sure KM can be able to do that, albeit it seems it’s a little more complicated to set up, and I’m still convinced that Automator would be able to do it if not for the weird Spotlight and permissions bugs. If I could do it all with KM that would make my day - I don’t like having a lot of apps running in the background at all times…
I’m also using Free File Sync to make sure all of my backup drives are updated and identical, maybe I can look a little deeper into it since it seems it would be possible to do.
...which is what you're doing in your example (though you may have to add a pause or check to make sure the new item is "complete" before doing anything with it).
It's much more difficult to deal with additions to sub-folders:
...because KM's trigger can't see beyond "Watched Folder" -- you'll have to set up triggers for each and every sub-folder, or periodically list the contents of "Watched Folder" and all its contents then compare that to the previous list, acting on any changes.
Sub-sub-folders add yet another layer...
Automator has the same problem because it uses the same event trigger -- a change to the folder being "watched", which does not include changes to the folders inside the folder being "watched".
Hazel can do sub-folders, which is why it is so often recommended for this kind of task. It's battle-tested, light-weight, and -- unless you want to do this in KM for the learning -- well worth paying for. You'll also find many more uses for it -- categorising files by their content, for example.
I should probably add at this point that I'm not a shill for noodlesoft and, while I've played with it, I'm not actually a Hazel user! But many people, both on this Forum and elsewhere, whose opinions I respect swear by it for automated file organisation.
Of course, that makes total sense! I’m still very much a KM noob, but I was so amazed by its performance when setting up custom keyboard shortcuts for Pro Tools (what a time saver…my right-hand tendinitis thanks you too, KM) that I figure there might be a way. I’ll have to have a look at Joel’s suggestion using Regular Expressions, but that might very well be beyond my abilities for now.
Right now Hazel is giving me a little bit of trouble, when I bounce my mixes on Pro Tools the mp3 file in my Bounced Files folder is created instantly but has to wait for the bouncing process to end before it has the correct file size, but Hazel instantly copies (or moves or syncs) the incomplete mp3 file to Google Drive.
As @Nige_S is aware, I was considering using Hazel but decided to build my own version for the learning experience. It has now morphed into having more functionality than Hazel although there are still a few things I need / want to add.
I decided to build my own both to learn and because I only had 1 folder to monitor. I suppose you could make it work but it would be a lot of macros / triggers (i.e., one for each subfolder)!
I tried Keyboard Maestro 5 years ago and gave up, too difficult for a non-programmer. This time was a different experience because of AI which means Regular Expressions are manageable by doing the following:
b) Provide an AI Tool with sample strings of test and tell it what you a Regular Expression for. It usually gets it on the first few tries and DONE!
If you would like a copy of what I built I am happy to share I just need to sanitize a few items of personal information should you think it would help.
One way to do it which would be very easy would be by i) setting up a macro for each folder which would i) record the file path and ii) call a macro / subroutine that would then move the file (i.e., each folder would only have two actions but they would be identical to every folder so no time at all to copy unless you have 100's of folders). The key point being you would only have one macro / subroutine that does the heavy the lifting, the others would simply be feeders. Very easy to adapt my macro to do just that plus you would not have to deal with the date wrangling, OCR, text conversion that I deal with!
4 AND A VERY IMPORTANT POINT which @Nige_S , @griffman and others have shared with me and I have converted to! At first I wanted to do everything in Keyboard Maestro so everything was centralize but have learnt that there is no one tool that does everything so I have now included on my automation / workflow Keyboard Maestro along with i) Moom ii) CLI Tools (Ghostscript, OCRmyPDF, pdftotext, and ReferencePreset) and iii) Shortcuts (as much as I dislike it).
Keyboard Maestro is the hub that bring everything together but where there are better / easier tools out there, use them!
I do consider Hazel one for those but I am so deep into my macro (and loved the added functionality that it offers), I am sticking to it!
Yes -- because, just like KM, the workflow is triggered when the folder is changed (the new file is created) not when it finishes changing (writing is complete).
The simple way round that is to add a "Pause for n seconds" Action to your Hazel workflow, before the "Move" Action. You can then optimise the flow by changing the "Pause" for something keeps checking the file size, only letting the flow continue once the size stops changing.
How to do that in Hazel is probably best asked on the Hazel Forums -- but have a search first as this is a common problem. It's also been covered here many times, most recently here.
Yep, actually it was indeed just as simple as adding a “date modified is not in the last 1 minute” rule before the “move to folder” rule, that worked like a charm !