kristofg / rifec

Receive Images From Eye-Fi Cards
GNU General Public License v2.0
53 stars 16 forks source link

Same Filename handling #4

Open mawosch opened 11 years ago

mawosch commented 11 years ago

After transfering some pictures I formated the Eye-Fi card. Then started again with shooting and transfering. The camera gave pictures the same filename. The problem was solved by the software to add a ".1" behind file extension. Thats a problem for normal file handling on computers. Could you change the renaming behaviour to "DoubleFilename-A.jpg" or somthing like that?

kristofg commented 11 years ago

Hm, yeah, that's true. I've set all my cameras to use sequential file names (ie. don't reset the counter when the card is emptied), so all my .1 files tend to be duplicates. I haven't really considered the use case where you want to keep both versions.

I'm a bit sceptical of messing about "inside" the file names; a trailing .1 is easy to identify and remove. foo123.jpg -> foo123-A.jpg / foo123-1.jpg / foo123+1.jpg can be much harder to identify unambigously (depending on the camera naming scheme, of course). But that may be too much paranoia. I'll have to think about it for a bit.

To solve your immediate problem, the sprintf() call in RIFEC::File::_link_file() would be the place to look. For your use case, I'm guessing you could change the single sprintf() to something like this (Note: this code is NOT TESTED):

my ($base, $ending) = split /\./, $destination_name, 2;
my $newbase = sprintf("%s+%d", $base, ++$tries);
$dst = join('.', $newbase, $ending);