elodie icon indicating copy to clipboard operation
elodie copied to clipboard

Properly handle conflicting file names by appending a number to the name

Open jalsin82 opened this issue 9 years ago • 2 comments

i.e. elodie.py import --new-filename --destination="path2" --source="path1"

Currently, if a picture named IMG3.jpg is imported, the new filename seems to be yyyy-mm-dd_hh-mm-ss-IMG3-[Title]-[Album].jpg. Is it possible to have an option that recreates the filename without including the original filename (IMG3)? In reading other posts, there seems to be a concern with duplicate filenames. Is it possible to handle any duplicate filename errors by appending an incrementing number to the complete filename?

jalsin82 avatar Jan 03 '17 14:01 jalsin82

Replied to #107 to keep all the comments together.

jmathai avatar Jan 03 '17 16:01 jmathai

Since this is the only issue preventing me from implementing elodie across my and my wife's picture library, I'm still interested in the having elodie create a completely new and unique name.

I don't understand why a separate database would have to be used to track the last number assigned. When elodie creates a filename from the date and time, most of the time this filename will be unique. In the event that this method does not create a unique file name, why can't elodie just append an incrementing number to the filename - like Windows currently does. For example, if I select 4 files in Windows an rename them all simultaneously the result will be filename.ext, filename (1).ext, filename (2).ext, and filename (3).ext. If I select 4 more files in the same folder and rename them at the same time the result will be filename2.ext, filename2 (1).ext, filename2 (2).ext, and filename2 (3).ext. If I select 2 more files in the same folder and rename them with the same new filename as the first file the result will be filename (4).ext and filename (5).ext.

Would it be possible for the rename routine to do something along the lines of: build new filename in temporary variable initialize temporary counter variable to 0 if new filename does not already exist: rename file to new filename if new filename already exists: increment counter by 1, append incremented counter to filename, check if new filename with counter already exists if the new filename with counter already exists: increment counter by 1, and repeat until unique filename is found (obviously there would need to be some point in which it fails, but it's highly unlikely that there is going to be 1,000,000 pictures in one folder all with the same filename generated by elodie)

In this way, I would think elodie could create completely new and unique filenames for imported pictures without having to create additional databases to track a file counter.

You have done a very thorough job with elodie. So I have to believe that you have already considered this as a solution. So, I guess I'm really just curious as to why this solution does not work. And, then, I guess my request is to continue searching for an appropriate solution that allows elodie to generate a completely new and unique filename.

jalsin82 avatar Jan 10 '17 14:01 jalsin82