INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Rename and move photo's based on databse fields, avoid duplicates  (Read 476 times)

najarip

  • Recent member
  • *
  • Posts: 36

Hi, for a very long time I have been organizing my mp3 collection with the rename and move functionality. mp3's get renamed en sorted in album/artist folders automatically,with a unique name. Very handy

With my photos I want to do the same, but I run into a problem, because I have multiple photos belonging to f.i. 2003/USA/Party Uncle. I want to rename the photos, because they have been moved around a lot, with different naming conventions. Is there a way to avoid duplicate names in this scenario? Maybe there is an autonumber database field I can use? Ie. Photo 1, Photo 2 etc. Maybe unique numbers per folder or for the database?

Any ideas are welcome. The photos are already in the library for the most part.
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9217
Re: Rename and move photo's based on databse fields, avoid duplicates
« Reply #1 on: October 29, 2023, 11:57:28 am »

Maybe there is an autonumber database field I can use? Ie. Photo 1, Photo 2 etc. Maybe unique numbers per folder or for the database?

Any ideas are welcome. The photos are already in the library for the most part.
The [CustomData()] expression function should work nicely for you here.
Logged

Some alternative skins are here | Import Stats on Steroids | Middle click the close button=One of the neatest things added to MC in a long time

najarip

  • Recent member
  • *
  • Posts: 36

Hi Marko,

Thanks for your usefull reply, I have been using CustomData but I have a question/challenge.

When I am updating my photos I use the Rename/Copy functionality. With Custumdata I get unique numbers, but as I understand, this CustomData works per batch. So if I rename 100 photos, it will use 1-100 in this batch. If I rename a bigger batch (say 200), with images I have already renamed in the first batch, these images will get a new unique number. For MC this is not a problem, but for Synology photos, that I also use, it is. It views the twice renamed photos as new photos because of the other name.

Is it possible to create database field to give every item in the database a unique number, that always stays the same? I think this will solve my problem, or is there a way to use CustomData and make sure that the generated numbers are always the same for a particular file?

So if I have 20000 files, every one of them will have a unique number in database field ' UniqueID' ranging from 1 to 20000.


Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2057

You could use timestamp prefix in the filename
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9217

Hi Marko,

Thanks for your usefull reply, I have been using CustomData but I have a question/challenge.

When I am updating my photos I use the Rename/Copy functionality. With Custumdata I get unique numbers, but as I understand, this CustomData works per batch. So if I rename 100 photos, it will use 1-100 in this batch. If I rename a bigger batch (say 200), with images I have already renamed in the first batch, these images will get a new unique number. For MC this is not a problem, but for Synology photos, that I also use, it is. It views the twice renamed photos as new photos because of the other name.

Is it possible to create database field to give every item in the database a unique number, that always stays the same? I think this will solve my problem, or is there a way to use CustomData and make sure that the generated numbers are always the same for a particular file?

So if I have 20000 files, every one of them will have a unique number in database field ' UniqueID' ranging from 1 to 20000.

For customdata(#), no.

The counter() function allows you to set a start number, and an increment value, but, is fraught with issues when used in the F6 tool, because the values increase ad-infinitum when the mouse passes over the 'before/after' list. The values reset after five seconds of inactivity. You then have to trust in the F6 tool and just hit the OK button, keeping the mouse out of the preview area. It's far from ideal. It's the reason customdata(#) exists. Finally, I don't think it fits your target destination.

You do have several options available to you though...

By default, MC comes with a [Date (filename friendly)] field. This can be useful for photos that have 'Date/Time Taken' data. The value in that field is derived from the [date] field, formatted like so: 20240828-091437

This would mean that they sort nicely too, with very little possibility of filename clashes. The probability of filename clashes increases by quite an order of magnitude if your files do not have time taken data. In those cases, the data in that field would look like: 20240828-000000

To be completely certain of a unique numerical identifier, per file, without having to concern yourself with "Does the date have time data?" or not, up to a maximum of 99,999 files would be to create your [UniqueID] field and add it to your image file tagging template. If you need help with any of that, just ask. I'm not sure how far along the learning curve you are currently.
Just be aware that if you keep the option to "Also save data to the file tags" All files on disk will be affected, which comes with the potential of the possibly unexpected or unwanted side effect if you run backup software, as it will see all those files as changed and set about it's task. This might not affect you, but it's a real thing for many people, which is why I mention it. You will know what's best for you.

Having created the field and added it to the tag window, you would then:
Select your 20,000 files. (If your nervous, try with, say, ten to begin with. What follows assumes you did this.)
In the tag window, click on your UniqueID field to open it up for editing. You would enter in there:
Code: [Select]
=padnumber(counter(),5)and press enter.

Now, the first ten should be numbered
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010

All good so far?

Now select the other 19,990 files, click your UniqueID field to open it for editing, and this time, you would enter:
Code: [Select]
=padnumber(counter(11),5)
Which will number the files from 00011 to 20000
If you chose not to save in file tags, this process will be almost instantaneous. If you opted to save in file tags, it will take longer to complete as every file will need to be written to on disk.

If you then add more files at a later date, you would need to populate the UniqueID field for them manually. There would be no way to automate this, as far as I'm aware. Perhaps something a bit more complex along the lines of math(max([UniqueID])+1) might work if inserted into the counter() expression, I do not know for sure, and do not have time to test it.

Determine the max value of your UniqueID field. Currently, for this exercise, we know it's 20000.
Select the new files and edit the UniqueID using:
=padnumber(counter(20001),5)

Note that once you get over 9,999 you no longer really need the leading zeroes, so from there on, you can safely use the simpler:
=counter(20001)

Once you have your head around it, it'll be infinitely quicker to manage than the time it's taken you to read all this.
With the data in place, you can then use the [UniqueID] field in your F6 rules.

See if any of that fits your use case/workflow needs and let us know if you have any doubts.

-marko
Logged

Some alternative skins are here | Import Stats on Steroids | Middle click the close button=One of the neatest things added to MC in a long time
Pages: [1]   Go Up