I need a script for renaming files

Discussion in 'macOS' started by Cox Orange, Jun 14, 2015.

  1. Cox Orange macrumors 68000

    Jan 1, 2010

    I have the problem that my TV saves mts files the following way:
    1st 12min. name.mts
    2nd 12min. name.mts1
    3rd 12min. name.mts2

    I would rather like to have it (on my computer)
    1st 12min. name.mts
    2nd 12min. name1.mts
    3rd 12min. name2.mts

    So, can someone write me a script (if that is not asking a lot) that replaces "anyname.mtsX" with anynameX.mts"

    So to say I only want to move the number from behind the mts before the dot in front of the *mts. The names shall be unchanged.

    Mind, the first file belong to one documentary always starts without number.

    Thank you. (I don't do coding and only can type in terminal, what people tell me I should type, so I don't know, if it is a bit harsh to ask for something like that).
  2. motulist macrumors 601


    Dec 2, 2003
    I presume you want to do this because only files ending in ".mts" will play correctly. If that's the case then a simple automator script will do it, albeit in an ugly way. Just make an automator script to add ".mts" to the end of all selected file names. The result will look like this:

    1st 12min. name.mts.mts
    2nd 12min. name.mts1.mts
    3rd 12min. name.mts2.mts
  3. Cox Orange thread starter macrumors 68000

    Jan 1, 2010
    perhaps a bit ugly, but it will do it well. Good recommendation. I will have a look into automator and how to work with it.

Share This Page