Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.5: How to increment trailing digits in copied files' names Desktop
In the Finder, there are numerous ways to duplicate a given file: either copy and paste the file to the same place, Option-drag the file to the same folder, or Control-click on the file select Duplicate from the contextual menu (or just press Command-D in the Finder).

Interestingly, the behavior of renaming the copied file for these three commands differs slightly. While duplicating or copying and pasting appends copy to the end of the filename (unless it already ends in copy, in which case it begins to enumerate) option-dragging the file to the same folder results in a slightly more useful naming system.

If the original file does not end in an integer, the new filename will be appended with the number 2 instead of copy. If the original ends in an integer, however, Finder does something quite useful -- instead of appending 2 to the end of the file, it recognizes the integer and adds one to the value.

For example, Report.doc will be renamed to Report 2.doc, but Report Number 67.doc will be conveniently renamed to Report Number 68.doc.

[robg adds: This is marked 10.5 only as I believe this behavior was new in OS X 10.5.]
    •    
  • Currently 1.89 / 5
  You rated: 1 / 5 (9 votes cast)
 
[6,930 views]  

10.5: How to increment trailing digits in copied files' names | 8 comments | Create New Account
Click here to return to the '10.5: How to increment trailing digits in copied files' names' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.5: How to increment trailing digits in copied files' names
Authored by: foucic on Jun 02, '09 08:09:16AM

The integer recognition and the subsequent +1 addition works only if the integer in the last position is preceded by an empty space. So, if the name of the file is 'Report Number 67.doc' you'll get the copied file 'Report Number 68.doc'. On the other hand, if the name of the file is 'Report Number67.doc', you'll get the new file with this name: 'Report Number67 2.doc'.
Pity.



[ Reply to This | # ]
10.5: How to increment trailing digits in copied files' names
Authored by: asmeurer on Jun 02, '09 09:37:05AM

This works if the number is padded with zeros (including with the number 0), but it removes the padded zeros from the copied file. So file 001.txt goes to file 2.txt and file 00.txt goes to file 1.txt.



[ Reply to This | # ]
10.5: How to increment trailing digits in copied files' names
Authored by: osxpounder on Jun 02, '09 12:22:09PM

Ouch! Glad you pointed that out. I like those leading zeroes, and use them often.

Good hint, good replies.



[ Reply to This | # ]
10.5: How to increment trailing digits in copied files' names
Authored by: manxman on Jun 02, '09 11:50:28AM

On a similar tack, I frequently want to save views from a particular webcam. Naturally, the webcam image's filename doesn't change, but dragging the image from Safari to a folder repeatedly, results in the filename usefully having -1, -2, etc, added to the filename. Also works in Camino, so it will probably work in any browser.



[ Reply to This | # ]
10.5: How to increment trailing digits in copied files' names
Authored by: macosnoob on Jun 02, '09 02:40:07PM
To take this one step further, you can also option-drag multiple files to the same folder for rapid generation of sequentially numbered files. Let's say you already have file, file 2, file 3, and file 4. Selecting all four and then option-dragging to the same folder produces file 5, file 6, file 7, and file 8. Etc.

[ Reply to This | # ]
points of view
Authored by: magnamous on Jun 02, '09 08:08:28PM

I can see how this could be useful, but personally, I'd file this one under "bug" rather than "feature". To my mind, file-renaming by the OS during a copy should be consistent, regardless of which way the copy command was initiated. It's particularly strange to have it work the same way in 2 out of 3 methods, and a different way in the 3rd method. To my mind, the behavior should be consistently predictable from the point of view of the "uninitiated user".



[ Reply to This | # ]
10.5: How to increment trailing digits in copied files' names
Authored by: tobyvoss on Jun 04, '09 01:22:50AM

i can confirm that this doesn't work in 10.4.: all described ways to duplicate a file in the finder rename the duplicate "filename copy number.extension" with the first copy having no number and leading space at all.



[ Reply to This | # ]
10.5: How to increment trailing digits in copied files' names
Authored by: ecbtln on Sep 02, '09 06:55:13PM

Behavior is the same on Snow Leopard...



[ Reply to This | # ]