Skip to main content
added 195 characters in body
Source Link
Stéphane Chazelas
  • 584.6k
  • 96
  • 1.1k
  • 1.7k

With zsh:

zmodload zsh/files
autoload -Uz zmv
mkmv() { mkdir -p -- "$2:h" && mv -- "$@"; }
zmv -n -P mkmv '(<1600-2020>(-<1600-2020>|)-[^0-9-][^-]#)*(#q.)' '$1/$f'

Remove -n (dry-run) when happy that it does what you want.

(zmodload zsh/files is to make mkdir and mv builtin to speed things up as you have thousands of files to rename which means as many invocations of mkdir and mv).

With zsh:

autoload zmv
mkmv() { mkdir -p -- "$2:h" && mv -- "$@"; }
zmv -n -P mkmv '(<1600-2020>(-<1600-2020>|)-[^0-9-][^-]#)*(#q.)' '$1/$f'

Remove -n (dry-run) when happy that it does what you want.

With zsh:

zmodload zsh/files
autoload -Uz zmv
mkmv() { mkdir -p -- "$2:h" && mv -- "$@"; }
zmv -n -P mkmv '(<1600-2020>(-<1600-2020>|)-[^0-9-][^-]#)*(#q.)' '$1/$f'

Remove -n (dry-run) when happy that it does what you want.

(zmodload zsh/files is to make mkdir and mv builtin to speed things up as you have thousands of files to rename which means as many invocations of mkdir and mv).

Source Link
Stéphane Chazelas
  • 584.6k
  • 96
  • 1.1k
  • 1.7k

With zsh:

autoload zmv
mkmv() { mkdir -p -- "$2:h" && mv -- "$@"; }
zmv -n -P mkmv '(<1600-2020>(-<1600-2020>|)-[^0-9-][^-]#)*(#q.)' '$1/$f'

Remove -n (dry-run) when happy that it does what you want.