0

Are there any hot keys to move folders up or down through parent folders and subfolders in MacOS?

e.g. In this simple example I want to move File 1234.pdf to Folder A, which would leave Subfolder A empty. Ideally I'll be able to do this using just keyboard. Bonus points: A hotkey to re-select the last selected subfolder (so that I can delete, rename, etc.).

- Folder A
   - Subfolder A
      -File 1234.pdf 
- Folder B
  • 1
    There's no built-in hotkey for that, but you can create such custom file actions with Alfred. Alfred also has built-in hotkeys for selecting the current file and moving it to any folder (using fuzzy matching). Requires the Powerpack though: alfredapp.com/powerpack – slhck Mar 2 '18 at 20:41
  • Try asking here: apple.stackexchange.com – HackSlash Mar 2 '18 at 20:57
  • 1
    @slhck No need to use Alfred. You can create a Finder service with a keyboard shortcut that will do this for you. – CJK Mar 2 '18 at 21:29
  • 1
    @CJK Sure, technically there's no need for it, it's just quite a lot more work :) – slhck Mar 4 '18 at 19:14
  • 1
    @slhck Yup, as I found out. It took me ages to write and test the script in my answer below! 🙂 – CJK Mar 4 '18 at 21:20
3

I apologise for the delay in getting back to you with my answer. It's been more challenging than I had anticipated.

But it is possible to achieve what you want by creating a service in Automator, which will then become accessible via a keyboard shortcut (hotkey).

You'll need to follow this guide on Making a Systemwide Service.


Start by creating a new service in Automator. It will need to receive files or folders as input, and be made available in Finder.

Add a Run AppleScript action to the workflow. In the text area of that action, the following AppleScript can be copied and pasted:

    use Finder : application "Finder"

    property F_ : missing value -- The previous folder
    property f : missing value -- The files that we moved
    property home : Finder's home as alias


    on run {f, _}
      get its ParentFolderOf:(some item in f)
      set there to the result -- The destination folder, one level up

      -- We won't navigate any higher up the folder tree than
      -- the home folder
      if (its ParentFolderOf:home) is in there then return

      -- Also don't apply this service to other folders that aren't
      -- in the same branch of the folder tree as the home folder
      if (there as text) does not begin with (home as text) then return

      -- The folder we're currently at
      tell Finder to set F_ to ¬
        (the container of some item in f) as alias

      -- Check to ensure there are no files in the destination folder
      -- that risk being overwritten.  If there are, we won't move
      -- the files who share the same name, i.e. only move those that 
      -- are safe to move.
      tell Finder to ¬
        repeat with _g in f
          get name of _g
          set g to [there as text, result] as text
          if not (g exists) then set end of f to _g
          set f to the rest of f
        end repeat

      -- Move the files
      tell Finder ¬
        to set f ¬
        to (move f to there) ¬
        as list as alias list

      -- Reveal them
      reveal f
      activate Finder
    end run


    to ParentFolderOf:(f as alias)
      local f

      set F_ to [f, "::"] as text as alias

      if (f as text) ends with ":" then return F_

      return its ParentFolderOf:F_
    end ParentFolderOf:

Save the service as whatever you like. Automator automatically saves it in the right location (~/Library/Services). I saved mine as "Ascend in Finder".

Next, you have to create a keyboard shortcut. This is done through System Preferences:

Keyboard shortcuts

Under the services list, you'll need to scroll down to the section marked Files and Folders, under which your service name should appear. You can see mine highlighted. I created the shortcut for mine (Ctrl+Up).

Now, every time I select files and/or folders in Finder and press , those files and folders ascend one level up the hierarchy into their parent folder. If I want to move them back, I can press Z to undo the move.

I put a safeguard in so that files and folders wouldn't get moved any higher up the folder tree than your home folder. It's unlikely you'd need to anyway.

1

If you work in Column view, you can navigate just with the Arrow keys.

For your example, assuming you start with your file selected...

  • Cmd ⌘ C to Copy

  • Left Arrow [this will select subfolder A], so for bonus points...

    • Enter ⌅ will allow you to rename it, or Cmd ⌘ Backspace ⌫ to delete it
      [This will not lose your file currently in the copy buffer]
  • Left Arrow [this will select folder A]*

  • Cmd ⌘ Opt ⌥ V to Move

This is the structure as it appears at the beginning.

enter image description here

and again at the end [after having deleted Subfolder A on our way past]

enter image description here

*Because it doesn't get mentioned anywhere in the answer, at this point the down arrow would select folder B

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.