Forrest logo
back to the mmv tool

mmv:tldr:b3dd5

mmv: Convert dates in filenames from "M-D-Y" format to "D-M-Y" format.
$ mmv "${[0-1][0-9]-[0-3][0-9]-[0-9][0-9][0-9][0-9]-txt}" "${#3#4-#1#2-#5#6#7#8-txt}"
try on your machine

This command is using the mmv tool to rename multiple files at once. mmv is a command-line utility for moving, renaming, and copying files.

Let's break down the command:

"${[0-1][0-9]-[0-3][0-9]-[0-9][0-9][0-9][0-9]-txt}": This is the pattern of the original file names. The pattern is enclosed in double quotes ("") to prevent any interpretation of the special characters by the shell.

The pattern [0-1][0-9] matches any number in the range of 00-19. The pattern [0-3][0-9] matches any number in the range of 00-39. The pattern [0-9][0-9][0-9][0-9] matches any four-digit number. The pattern -txt matches a literal string "-txt".

"${#3#4-#1#2-#5#6#7#8-txt}": This is the pattern to which the original file names will be renamed. Again, the pattern is enclosed in double quotes.

The # character is used to reference specific parts of the original file name.

  • #3 refers to the third digit of the original file name.
  • #4 refers to the fourth digit of the original file name.
  • #1 refers to the first digit of the original file name.
  • #2 refers to the second digit of the original file name.
  • #5 refers to the fifth digit of the original file name.
  • #6 refers to the sixth digit of the original file name.
  • #7 refers to the seventh digit of the original file name.
  • #8 refers to the eighth digit of the original file name.

The renamed file will have a new format #3#4-#1#2-#5#6#7#8-txt, where the original digits are rearranged.

For example, if the original file name is "01-18-2022-txt", it will be renamed to "1801-22-txt" based on the pattern ${#3#4-#1#2-#5#6#7#8-txt}.

Note that the mmv tool must be installed for this command to work.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the mmv tool