First, I apologize for my 'noobness' with Linux and the shell. I'm running Ubuntu with zsh as my shell.
What I'd like to be able to do is clean up a messy Downloads folder by moving categories of files to different directories with something like:
mv dir/$vids dest
mv dir/$music dest
mv dir/$pics dest
where the variable would expand to a pattern for those types of files before execution.
I tried setting pics='*.(#i)(jpg|jpeg|gif|png|bmp)' but that didn't work. So is there any way to do something like this or do I have to write my own function? It just seems like a real pain to write a function for every instance where I'd like to manipulate certain types of files. Maybe I'd like to copy all pictures, or list only movies in a directory, or find all music, etc.
Thanks for the replies. So I take it there is no easy way of basically using an alias in the middle of a command? I find it hard to believe that no shell would come up with a syntax for it, unless there are potential problems that I'm not thinking of.
If anyone feels like critiquing my attempt at writing a function to do this, I wouldn't mind. I imagine I could expand this to just a function like "pics" and then accept parameters for copy/move/list/etc.
mvpics() {
if [[ -d $2 && -d $1 ]] ; then
mv $1/*.(#i)(jpg|jpeg|gif|png|bmp) $2
elif [[ -d $1 && $# == 1 ]] ; then
mv ./*.(#i)(jpg|jpeg|gif|png|bmp) $1
else
echo 'mvpics <origin> <destination> or mvpics <destination>'
fi
}