Resolved rename multiple files?

Discussion in 'Mac Basics and Help' started by Kaspin, Dec 30, 2015.

  1. Kaspin macrumors member


    Jan 15, 2015
    I have lots of files named with the format of "Sometext_MMYYYY.pdf" (MM=month YYYY=Year) and I want them all as "Sometext_YYYYMM.pdf" so they're sorted chronologically. Is there anyway to automate this?
  2. Kaspin thread starter macrumors member


    Jan 15, 2015
    I ended up using numbers to create a mv command list to paste into terminal using the MID string function. Screen Shot 2015-12-31 at 11.06.30 AM.png

    I was hoping to find a way to do it just in terminal, but I was only able to find syntax for replacing specific strings in file names, nothing similar to MID string function in numbers.
  3. chown33 macrumors 604

    Aug 9, 2009
    The bash syntax for "substring" is:
    Refer to the bash man page, and find Substring Expansion on the page.

    If I were doing this, I might have looked up the bash syntax, made a test that echoed the cmds, and done it that way. More likely, I would have made a small 'awk' program to do what you did: read inputs, transform into a series of 'mv' commands, then run the resulting cmds (i.e. piped to bash). This is mainly because I know awk.

    There are many other ways of doing the same thing, and Numbers is as good a way as any. The key insight is to see it as a problem of converting a series of names into a series of commands, then running those separately. Nice solution using Numbers.

Share This Page