Move folder contents out of folder

Hi,

Struggling to kludge my way through something (hopefully) simple.

I'd like a macro that moves the contents of selected folders into the current location, and deletes the folders.

So this:

Becomes this:

Thank you for any guidance.

Judging by the images you show, is this what you mean?:

For each selected folder, move the folder’s contents to the parent folder then delete the selected folder.

Is this correct?

Also, what if a file with the same name already exists?

Yes.

Originally I'd planned to check for that manually; however, if we could change the name of the file we're moving to the name of the folder it is in, that would solve the problem. Here is an example from the actual work I need to do:

Turn this:

Into this:

That shouldn't be problematic, because there will only ever be one file in each folder, and all folders will be unique.

The rename/move/delete actions I understand. They are the opposite of an "Enclose in folder" macro that I got from @peternlewis somewhere on the forum. It's getting the contents within the folder without seeing them that's got me stymied.

PS: This is what happens when I post so late and so tired... low quality and lacking detail! Sorry! :slight_smile:

LOL. Been there too many times. :slight_smile:

I'm sure there are dozens of ways to do this. Here's one way:

Move Selected Folders' Files to Parent Folder and Delete Folder.kmmacros (8.9 KB)

  1. You need to write the code that tests for duplicates and handles them somehow.
  2. You'll probably want a confirmation prompt at the start.

I know that as soon as I post this, someone will post a much simpler way. :slight_smile:

1 Like

Thanks Dan! I will tweak it some but this gets me 99% there.

1 Like

FYI: Hazel can do that much more easily, if you have have, or are thinking about, adding Hazel to your Mac automation toolkit.

1 Like

OH! I do! Let me dig in there. Thank you.

1 Like

and just that quickly–using some shell script with zero knowledge of how it works–I made some pretty catastrophic changes that seems to have deleted, well, all of my documents, preferences, etc.! Dropbox folder gone too. Thankfully my backup game is on point, and I run fairly lean. Whoops!

As an aside, anyone know where system preferences live? Things like scroll direction, dock placement, etc.? If it’s in the home folder I’m good, if not I’m starting over :slight_smile:

Ahhhhhhhhhhhhhhhhhhhhhhhhhhhh! :open_mouth:

And no, I don’t know where it’s stored.

By the way, that’s why I always use the “Trash” action to delete files/folders. You just never know…

I’d been meaning to put Arq through its paces anyhow!

1 Like

Many, if not most of them should be in

~/Library/Preferences/ByHost

An important one is the .GlobalPreferences.<UUID>.plist in that folder. (Since it is a dot file, it’s not visible in the Finder.)

1 Like

I’ll add those to my backups now. Thank you

Circling back to say thanks for this suggestion; I never tried it at the time, and I am now faced with larger numbers of files to "unfolder," so my kludgy macro was no longer cutting it. I've started thinking in "buckets" for Hazel in the years since writing this post, and am now using these two rules below and a new "bucket" for this task.


https://www.noodlesoft.com/manual/hazel/advanced-topics/processing-subfolders/

1 Like

Right on!