Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Automator: Move parentFolder that contains a specific file extension

Hello,

I am trying to put a folder action on my "Downloads" folder to detect a .stl file downloaded. If detected I would like move the folder containing the STL file to another location. I cannot find anything online to move the parent folder, only posts about moving files out of subfolders or moving files into a parent folder.


Any help would be much appreciated.


thank you!

Posted on Sep 15, 2021 6:18 AM

Reply
Question marked as Best reply

Posted on Sep 15, 2021 9:58 AM

What you're asking for is actually kind of complex, at least if I'm understanding it correctly.


I think what you're saying is that you have something like:


Downloads
 |-Subfolder
  |-Some file.stl


and you want a Folder Action on Downloads that will detect a new .stl file in the Subfolder.

Additionally, you want the folder action to move the Subfolder to some other location.


This is going to be very hard, because the Folder Action attached to Downloads will only trigger for files added to the Downloads folder, not to any files added to subdirectories.


In order for the Folder Action to see the .stl file, it would need to be applied to the Subfolder, not to your Downloads folder.


That would work if you attached the FA to the Subfolder, but since your ask is to move the subfolder out, there's nothing to catch the next folder/stl file creation.


Two potential solutions come to mind:


1) What is the requirement to move the Subfolder? Would it be sufficient to create a new folder somewhere else and move the contents into this new folder, thereby leaving the subfolder with the folder action attached).


2) Use two Folder Actions. One that detects .stl files and moves the parent (this is attached to the subfolder), and another (attached to the Downloads folder) that attaches the 'stl detector' script to new folders.


All this is suspect, though, if you're downloading files. Folder Actions will trigger when files are added to the folder, but if you are downloading files, the file isn't necessarily complete by the time your FA kicks in. This means there is a potential for your script to move the file while it is still being downloaded, with unpredictable results.


Might need a deeper thinking on what you're trying to achieve.

3 replies
Question marked as Best reply

Sep 15, 2021 9:58 AM in response to bscott0588

What you're asking for is actually kind of complex, at least if I'm understanding it correctly.


I think what you're saying is that you have something like:


Downloads
 |-Subfolder
  |-Some file.stl


and you want a Folder Action on Downloads that will detect a new .stl file in the Subfolder.

Additionally, you want the folder action to move the Subfolder to some other location.


This is going to be very hard, because the Folder Action attached to Downloads will only trigger for files added to the Downloads folder, not to any files added to subdirectories.


In order for the Folder Action to see the .stl file, it would need to be applied to the Subfolder, not to your Downloads folder.


That would work if you attached the FA to the Subfolder, but since your ask is to move the subfolder out, there's nothing to catch the next folder/stl file creation.


Two potential solutions come to mind:


1) What is the requirement to move the Subfolder? Would it be sufficient to create a new folder somewhere else and move the contents into this new folder, thereby leaving the subfolder with the folder action attached).


2) Use two Folder Actions. One that detects .stl files and moves the parent (this is attached to the subfolder), and another (attached to the Downloads folder) that attaches the 'stl detector' script to new folders.


All this is suspect, though, if you're downloading files. Folder Actions will trigger when files are added to the folder, but if you are downloading files, the file isn't necessarily complete by the time your FA kicks in. This means there is a potential for your script to move the file while it is still being downloaded, with unpredictable results.


Might need a deeper thinking on what you're trying to achieve.

Sep 15, 2021 10:28 AM in response to Camelot

So to put some more context around the ask..

I am downloading various 3D Model files (for my 3d printer) and they download in various ways.. some will download with a main folder and 3 subfolders, one subfolder containing the .STL files I am looking for. Other times when downloading these models, the .STL file will download directly without any subfolder or main folder.


I guess I'm looking to do 1 of 2 things..1 would be to look for a .STL file in the downloads folder (including subfolders). If detected, move all parentFolders up to the Downloads folder to a new location. 2 detect the .STL file, append the name with the highest most parentFolder to the .STL file and move to a new location. thinking about it, I would prefer option 2. This may have complicated things more slightly, and if this simply can't be done within Automator, all good. I was able to at least detect and move my .STL files to a new location, just not as organized as id like it to be.


Thank you for the help and explanation above!

Sep 15, 2021 12:35 PM in response to bscott0588

The other part of this is how the files are downloaded. It isn't usually possible to download a folder from a web link. Instead, it's more common to download an archive (e.g. a .zip file) which gets extracted, restoring any folder structure in the .zip.


In this case, any folder action attached to Downloads would trigger twice - once on the initial download of the .zip file (a new file was added to the folder), and again when the OS extracts the contents of the .zip file after the download (a new folder is created), but not for each of the files in that subfolder.


What's really missing here is a 'post flight' option - the ability to trigger a script when the download completes. That would be ideal. Lacking that, though, it may be possible to get a folder action to work: a) ignore .zip files, b) if a folder is created, wait for the extraction to complete, then move files as needed.

As I said before, though, it's all a little more complicated.


The real issue is how to trigger the script. Folder Actions are not ideal for this. Is a manual script sufficient (i.e. an app on your desktop/dock that you click to scan for any .stl files in your downloads folder? It simplifies the flow at the cost of manually kicking off the process rather than complete automation.

If you prefer a hands-off solution, it needs a little more work to check when the .zip extraction is complete.

Automator: Move parentFolder that contains a specific file extension

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.