Taking in account that 1) Q said "large collection ... of files" - the list of files might not all fit in one command line buffer (2,084,684 bytes on MY system); and 2) Filenames might contain funny characters ("My Stuff.jpg
"); mv
is not the best way. Using find
, xargs
, and the sure knowledge that filenames must NOT contain NUL bytes (or slashes):
find /home/tony/Desktop/unsorted_files/ -maxdepth 1 -type f -iname '*.jpg' -print0 | \
xargs -0 --no-run-if-empty echo mv --target-directory=/home/tony/Desktop/jpgfolder
Once the echo
d commands look right, remove the echo
, and let mv
do the work.
If you have already done mv /home/tony/Desktop/unsorted_files/*.jpg /home/tony/Desktop/jpgfolder
BEFORE you created the /home/tony/Desktop/jpgfolder
, nothing has been lost, but you must, as other answers have said, mkdir -p /home/tony/Desktop/jpgfolder
first.
makedir /home/tony/Desktop/jpgfolder
and runmv /home/tony/Desktop/unsorted_files/*.jpg /home/tony/Desktop/jpgfolder/
mv
does not create folders. 1.mkdir -p /home/tony/Desktop/jpgfolder
; 2.mv ...