Artificial intelligent assistant

Bash - move files into numbered folders oneliner I can create multiple numbered folders at once like so: mkdir Season\ {1,2,3,4,5} Is there a way I can run the following commands in a oneliner (without a for loop): mv 01.* Season\ 1 mv 02.* Season\ 2 mv 03.* Season\ 3 mv 04.* Season\ 4 mv 05.* Season\ 5 Bonus points if there's a ZSH way to do it.

With `zsh`:


autoload zmv # best in ~/.zshrc
zmv -n '(<1-5>).*' 'Season $(($1))'


(remove the `-n` when happy)

Note that it calls one `mv` per file so it would be less efficient than the 5 `mv` commands of your question (unless you do a `zmodload zsh/files` beforehand to get a builtin `mv`).

A `perl`'s `rename` alternative:


rename -n '$_="Season $1/$_" if /0*(\d+)/' 0[1-5].*


(remove `-n` when happy)

Note that `rename` calls the `rename()` system call, so that only works to move files within the same file system (while `mv` will resort to copy+unlink when moving files across file system boundaries).

With `mmv` (moving across FS boundary is supported, but then note that not all attributes will be preserved and for symlinks a copy of the target file is created):


mmv -n '0[0-9].*' 'Season #1/'


(remove `-n` when happy)

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 9644def9f165aa435ffcd412e052a498