Comment 10 for bug 648424

Revision history for this message
Michael Hendry (hendry-michael) wrote : Re: [Bug 648424] Re: Export doesn't deal with different files with same filename

On Fri, 2010-11-12 at 20:31 +0000, Jim Nelson wrote:
> I think there's any number of ways we can go about doing this.
> Michael's ideas are great, but they involve a broader idea of exporting
> photos -- being able to customize names and ordering and numbering,
> almost like generating a report. That's a scheme far larger than this
> ticket.
>
> The problem here is when you export two photos with the same filename,
> the second one clobbers the first. That's obviously not right. What if
> we did something super-simple: When going to export the file, if the
> filename exists, append an underscore and a numeral and see if that file
> exists. If so, keep appending numbers until one is found.
>
> With this scheme you would get files like this:
>
> IMG_0123.JPG
> IMG_0123_1.JPG
>
> Not as powerful as Michael's idea, but it will work, and preserves the
> original filename (which is sometimes human-readable).
>
> As it turns out, we have code in Shotwell that does exactly this (we use
> it for import). In file_util.vala is a function generate_unique_file().
> The function returns a File object with a unique name (using the
> original if possible).

Thanks, Jim. Suffixing a serial number in the event of a duplicate
filename would certainly have solved my initial problem in a way I could
live with.

>
> This, I think, is the easiest way to go to solve this ticket. Michael,
> I think your ideas are interesting, as always. If you'd like to propose
> a new feature, I encourage you to file a ticket fleshing this out on our
> Trac server: http://trac.yorba.org.

As a recent convert to Linux from Windows, I find the idea of being able
to have a direct effect on the development of a product is very strange
and not a little frightening! I'll certainly have a look down this
avenue.

Michael