I am writing a simple method to mass move files and have attempted two approaches:
#(1)
find . -name '*.pdf' | xargs -I{} mkdir pdfs; mv {} pdfs
#(2)
find . -name '*.pdf' -exec mv {} pdfs \+
The first approach surprisingly worked 'sometimes', however, after deleting the folder with the pdfs a few times and returning the pdfs to the parent directory, it suddenly stopped working.
It produces the following error:
mv: rename {} to pdfs: No such file or directory
xargs: unterminated quote
Whereas the second approach gives the following error:
find: -exec: no terminating ";" or "+"
Update:
I got it working with:
find . -name '*.pdf' -exec mv "{}" pdfs \;
However, If I wanted to create the directory and move files in one line, this wont work, for example:
find . -name '*.csv' -exec mkdir -p csvs && mv "{}" csvs \;
find: -exec: no terminating ";" or "+"
How to implement directory creation and move?