Exclude folders

Is there a way to exclude only folders?
I want to move all files from my download folder to a specific folder automatically via shortcut,
but folders should stay in the download folder. Any suggestions?

I have a solution that involves a… shell script.

(Quelle surprise…)

find "$HOME/Downloads" -maxdepth 1 -mindepth 1 \! -type d -exec mv -v -n {} "$HOME/Some/Folder Name/Here/" \;

You could trigger that with a Keyboard Maestro shortcut.

Here's the breakdown…

  1. find "$HOME/Downloads"
    Hopefully this is obvious, but it says to look in the "Downloads" folder in your $HOME directory.

  2. -maxdepth 1
    Don't descend into any sub-folders found in $HOME/Downloads

  3. -mindepth 1
    This effectively excludes the $HOME/Downloads folder itself and makes sure we are inside the folder itself.

  4. \! -type d
    Find everything that is not  type d … and d stands for directory (aka folder)

  5. -exec mv -v -n {} "$HOME/Some/Folder Name/Here/" \;

  • -exec means “execute the following shell command”
  • {} means “any results of the find command”
  • \; means “this is the end of the shell command”
  • mv -v -n means move verbosely -v but “not overwriting” (-n)
  • "$HOME/Some/Folder Name/Here/" is the directory/folder that you want to move the not-folders to.

Questions? Let me know.


This can be done easily using all native, non-scripting KM Actions.
Let us know if you are interested.

1 Like

I am, I was searching for it for a while

Can you tell me more about it or send a link to the information? @JMichaelTX