With some shells, you could use extended globbing+certain flags to match only files in class one.
With bash
:
shopt -s extglob
for one in +([0-9])-+([0-9])-+([0-9])-+([0-9])-+([0-9])
do
[[ -f $one ]] && mv -- "$one" first-class
done
+(<PATTERN>)
matches one or more occurrences of the given pattern, [[ -f ... ]]
tests for regular file - if yes, it's mv
-ed to first-class
; to perform a dry-run, add echo
in front of mv
.
With zsh
:
setopt extended_glob
mv -t first-class [0-9]##(-[0-9]##)(#c4)(.)
x##
matches one or more occurrences of the pattern x
, (#cN)
requires exactly N
matches and (.)
matches only files
or:
autoload zmv
zmv -Q '[0-9]##(-[0-9]##)(#c4)(.)' first-class
-Q
turns on bare glob qualifiers, to dry-run add -n
e.g. zmv -Qn ...
If filtering regular files isn't needed then you can do without the testing in bash
:
shopt -s extglob
mv -- +([0-9])-+([0-9])-+([0-9])-+([0-9])-+([0-9]) first-class
and without the (.)
qualifier in zsh
:
setopt extended_glob
mv -t first-class [0-9]##(-[0-9]##)(#c4)
or
autoload zmv
zmv '[0-9]##(-[0-9]##)(#c4)' first-class