Batch Duplicate File > Then rename?

Discussion in 'Mac Apps and Mac App Store' started by eclipse525, Sep 7, 2012.

  1. eclipse525 macrumors 6502a


    Aug 5, 2003
    USA, New York
    I have a situation where I need to take a file and then duplicate the file several times renaming each new file by adding a length to the end of each one. Below is an example of what I am trying to accomplish. Is this something that would be appropriate for "Automator"? If so, how can I accomplish this task? Thank you for any help!*


    Original file name: *BOC-CABLE.jpg

    Need to create these variants:


    PS-> I''ve got the renaming thing down with an application called "A Better Finder Rename" but the tricky part is a duplicating the file and then renaming it to add the new part name.

    Thank you!
  2. GGJstudios macrumors Westmere


    May 16, 2008
    I think you may need to create the duplicates first, then rename them. To duplicate them, just copy the file and paste repeatedly in Finder. For renaming large numbers of files/folders, I use Name Mangler and I've heard good things about NameChanger.
  3. eclipse525 thread starter macrumors 6502a


    Aug 5, 2003
    USA, New York
    Yeah, I was afraid of that. I currently use "A Better Finder Rename" to rename files but it's the duplicating part that is tricky. I have SO many files I need to do this too that it's a scary thought. I'll keep looking in hopes that there is a solution. Thank you!

  4. GGJstudios macrumors Westmere


    May 16, 2008
    I don't know how many files you have, but duplicating is a very fast process. Just select the file(s) you want to duplicate in Finder, then press Command-C to copy. Then, while holding the Command key down, press the V repeatedly, for as many copies as you want.
  5. robgendreau macrumors 68040

    Jul 13, 2008
    I think the following would help in Terminal:

    for num in {001..10}; do cp file file.$num; done

    It would get you filename1.jpg, filename2.jpg, etc. So at least the duplication would be done; I don't know how you'd get the numbers you want since I don't know how they're generated.
  6. aalegado macrumors newbie


    Aug 24, 2001
    Lost Wages, Nevaduh
    Put this in a shell script:

    cp "$string" "$basename"03"$extension"
    cp "$string" "$basename"06"$extension"
    cp "$string" "$basename"15"$extension"
    cp "$string" "$basename"25"$extension"
    cp "$string" "$basename"50"$extension"
    cp "$string" "$basename"75"$extension"
    cp "$string" "$basename"100"$extension"
    When you execute it, supply the filename of the file that you wish to duplicate. If the filename is *BOC-CABLE.jpg then in the Terminal you would enter:

    ./ *BOC-CABLE.jpg
    The script will take the filename you input, and copy it each time putting a literal value between the basename and the extension. You can see in the script where the literal value is. This is brute-force code but it's easily extended: Just duplicate the

    cp "$string" "$basename"XX"$extension"
    line and replace XX with the value.

    Since the values are hard-coded in the script but you enter a filename each time, you can use this script against all the files that you have to copy/rename as long as they all need to have the same range of values.

    You could make this more elegant by putting the values in an array and then looping through the array and doing the cp operations using an indexed variable brain can't handle that right now. :)

Share This Page