I have the alias
alias moveit='mkdir $1 && find -name "*$1*" -type f -exec mv -t ~/$1 {} +'
But I'm not quite sure what I'm doing wrong.
Any help would be much appreciated.
I'm trying to make an alias where typing moveit pdf
- Creates a directory called
pdf
in the current working directory. - Searches for all the files that contain
pdf
in the name within the working directory and all of its subdirectories. - Moves those found files into the new folder called
pdf
.
I know that pdf
will return other files that aren't pdf
s. I'm essentially trying to create an automatic sorting script.
I have files called:
greatfile[pdf].rar
greatfile[txt].rar
greatfile[rtf].zip
badfile[pdf].zip
badfile[txt].zip
badfile[rtf].rar
okayfile[pdf].tar.bz
okayfile[txt].zip
okayfile[rtf].rar
And I want to sort these files into folders named pdf
, txt
and rtf
, all in one script, or at least one at a time for now.