OSX Terminal command to move all files in directory OSX Terminal command to move all files in directory shell shell

OSX Terminal command to move all files in directory


You're getting "too many argument" because there are probably too many files in ~/Desktop/dir/ that that are allowed by glob matching pattern on command line.

To move all files from ~/Desktop/dir/ to ~/Desktop/dir/dir2 use this find instead:

find ~/Desktop/dir/ -type f -execdir mv '{}' ~/Desktop/dir/dir2 \;

Or to move everything including files and directories use:

cd ~/Desktop/dir/find . -path './dir2' -prune -o ! -name . -exec mv '{}' ./dir2 \;

i.e. other than dir2 and . move everything to ~/Desktop/dir/dir2


*.* matches all filenames that have a dot in the second or further position. It will not match filenames that do not have a dot. Using * instead will match all filenames that do not start with a dot.