Directory structure....
--G
- Action.app (this Automator app)
- Random.app
- Folder 1
- File A.a
- File B.t
- File C.q
- Folder 2
- File D.a
- File B.t
- File C.q
I click-drag Folder 1
and Folder 2
and drop them on Action.app
. (The names of these folders are always different).
The Action.app
moves all files in the folders to the parent directory then deletes the folder. Duplicate files are overwritten during move. So I end up with:
--G
- Action.app (Automator app)
- Random.app
- File A.a
- File D.a
- File B.t
- File C.q
This works....
What I'm trying to accomplish....
The above automator action has the parent folder hard-coded in the steps - --G
– that's the parent folder. I want to remove that hard coded folder and make it relative to the items I've dragged (or location of the action.app). That way I can place this action in any directory and run it.
I have searched quite a bit and tried, I think, every question here regarding "getting parent folder" and none of them seem to work, using Applescript, shell scripts, etc. for this basic instance. In fact, one of the shell solutions started moving files and deleting directories on the startup volume/desktop (ooof!).
I've tried the following...
This does set the parentFolder
variable to the parent directory's name (verified in results).
But the variable parentFolder
is not an option for the Move Finder Items
step.
If I don't "ignore input" after setting the variable, then everything in the parent folder is processed (breaking the apps, because "Contents" is extracted from them) - the drag/drop doesn't target specific folders.
I realize I'm probably overlooking something simple. Any help?
In case: Mojave 10.14.6 / Automator 2.9