The target directory for the mv
you gave as /pdf
, you should have used ./pdf
. Since there was no directory (folder) named pdf
in the top-level directory /
, but since you were root
, mv
moved each of the files it moved to the file /pdf
. The only recoverable file is now called /pdf
, and was the last one processed by mv
.
As an aside, when I sudo find
, I ALWAYS use the --target-directory
switch to mv
, and run the find with echo
first, to ensure it does what I want, like this:
# NOTE: This demonstrates a FAIL
sudo find . -type f -iname '*.pdf' -exec echo mv --target-directory=/pdf {} \;
But, I'd probably do it like this:
mkdir ./pdf
find . -type f -iname '*.pdf' -print0 | xargs -0 mv --target-directory=./pdf
mv
will show an error message if the argument to --target-directory
does not exist.
I use find -print0
paired with xargs -0
to deal with file names containing spaces and other silly characters.