OSX Terminal command to move all files in directory

command-line-interface, macos, shell, terminal

Solution

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`

Problem

i'm at the OSX terminal now and try to move a lot of files from `~/Desktop/dir/` to `~/Desktop/dir/dir2`. Command ``` mv *.* ~/Desktop/dir/dir2 ``` doesn't work.

Original source