Have a large folder filled with a large collection of different files.Ideally, I want to shift all the different files into their respective folders; so jpg files into the jpg folder etc.
Original folder : unsorted_files
destination folder: jpgfolder
I tried
mv /home/tony/Desktop/unsorted_files/*.jpg /home/tony/Desktop/jpgfolder
But got an error "jpgfolder" is not a directory"
Best Answer
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. Usingfind
,xargs
, and the sure knowledge that filenames must NOT contain NUL bytes (or slashes):Once the
echo
d commands look right, remove theecho
, and letmv
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.