INTERACT FORUM

Please login or register.

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

Author Topic: Q: how to fill the NAME field with incrementing numbers?  (Read 8634 times)

ShayB

  • Junior Woodchuck
  • **
  • Posts: 97
Q: how to fill the NAME field with incrementing numbers?
« on: October 14, 2008, 01:36:32 pm »

hi,

What is the easiest way to rename my photos such that they will have a pattern of strings and incrementing numbers?
 (for example  Vacation_2008_###    where the ### are from 1 to some number according to a list of files that I generated)

Logged

gappie

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4580
Re: Q: how to fill the NAME field with incrementing numbers?
« Reply #1 on: October 14, 2008, 05:26:29 pm »

hi,

What is the easiest way to rename my photos such that they will have a pattern of strings and incrementing numbers?
 (for example  Vacation_2008_###    where the ### are from 1 to some number according to a list of files that I generated)


when you are looking at the list you have sorted select all the files you want to include and type in the name field (via the tag window or F2) 
=Vacation_2008_Counter(1)

make a backup of the library first just to be sure and try a few  first.

 :)
gab

edit : more about the counter is here:
http://wiki.jrmediacenter.com/index.php/Media_Center_expression_language#Counter.28....29:_Use_to_return_a_value_that_starts_at_one_and_counts_up_with_each_use
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9139
Re: Q: how to fill the NAME field with incrementing numbers?
« Reply #2 on: October 14, 2008, 11:41:35 pm »

You want to populate the name field within MC, or do you want to change the actual file name?

If it's the former, then do as gappie suggests, though you might prefer to add some padding: =Vacation_2008_padnumber(counter(1),3)
This will give you _001 as opposed to simply _1

If on the other hand, you actually want to rename the files themselves, the process is very similar.
Right click on the tag window and choose "Also show > Filename (name)"
Select the files you wish to rename in the file list.
You will notice that the Filename (name) info in the tag window now says "Varies". Click that to edit and paste in: =Vacation_2008_padnumber(counter(1),3).[file type]
Press enter to apply the changes and MC will rename the files incrementally for you, updating the database with those new names at the same time.

Later, if you wish to add more files to the sequence, you can choose to start counting from any point you like. You do that by specifying the start number in brackets after the word 'counter'. In our examples we've asked MC to start counting from one.

If you're not happy, ctrl + z will revert your changes if you press them before making any other tag changes.

-marko.

ShayB

  • Junior Woodchuck
  • **
  • Posts: 97
Re: Q: how to fill the NAME field with incrementing numbers?
« Reply #3 on: October 15, 2008, 03:36:20 am »

thanks gappie, thanks marko,

I wish I could do the counting by using a user-field and then just copy from that field to the correct one.
Somehow, when I define a field that does the count calculations, Everytime that the cursor is moving on the entry the field of that entry is going wild (doing incrementation without stopping). I don't know if it's a bug or not.

Shay
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9139
Re: Q: how to fill the NAME field with incrementing numbers?
« Reply #4 on: October 15, 2008, 03:44:52 am »

counter() is not designed to be used like that I'm afraid.

When used in the way described, it's a wonderfully powerful and relatively simple tool to use, or at least, I think so!

In what way are our answers still leaving you short?
If we know that, then it's quite possible we may have some helpful tips up our sleeves for you.

-marko.

ShayB

  • Junior Woodchuck
  • **
  • Posts: 97
Re: Q: how to fill the NAME field with incrementing numbers?
« Reply #5 on: October 15, 2008, 03:57:53 am »

hi Marko,
The answers are very good, thanks.

It's just that every time I want to rename fields using this method (which later will be renaming the filename using those tags)
I have to remember the correct syntax.

I would like to use a right-click menu-like method. in which, when I right-click and select the correct item (say, pattern-renaming) I will have a regular-expression entry which I can then save as preset for later uses.

The whole thing came up actually, because I was trying to upload to my new Ipod the photos. Due to different sources, I got duplicates of the names so I had to make tham unique. So, to make it simple, I renamed the "name" field to become
[album] padnumber(counter(1),3)

since this is "constant" and can be applied to all lists I thought I can define an extra field and then just copy from field to field.

if there is an easiest way (not having the need to remember the count+pad syntex), I will "take it"  :)

Shay
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9139
Re: Q: how to fill the NAME field with incrementing numbers?
« Reply #6 on: October 15, 2008, 12:47:13 pm »

I see.
The following will work for you...

make a library field called "Counter"
Make it "Calculated data" and use the expression =_padnumber(counter(1),3)
OK your way back out.

This field should not be used in any of your views, it's not meant to be seen.

Next time you want to batch renumber some files, select them, then use the steps outlined by myself and gappie, only now, you can enter any common string you want, followed by [counter] and the renumbering will take place as expected.

so, =Vacation_2008_padnumber(counter(1),3) would become =Vacation_2008[counter] and next time, you might want to choose =Christmas_2007[counter] and you'll get "Christmas_2007_001" etc. etc.

Caveats involved are minor...

1. If you run the [counter] field any time within five seconds of the last time, it will continue counting from where it left off last time.
2. It will always start from _001

Will that work for you?

-marko.

ShayB

  • Junior Woodchuck
  • **
  • Posts: 97
Re: Q: how to fill the NAME field with incrementing numbers?
« Reply #7 on: October 15, 2008, 02:20:12 pm »

Thanks Marko,

This is a very good solution, I tried it.
at first I forgot to put the "=" so I picked again at your colored exampled

 :D

I wish it could be also done for the directory-renaming-expression
(I defined a field to compute where every file will go to but the rename tool changes the "\" with "_")
So I have to write the expression directly to the directory rule.

thanks,
Shay
Logged

gappie

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4580
Re: Q: how to fill the NAME field with incrementing numbers?
« Reply #8 on: October 15, 2008, 03:00:53 pm »


make a library field called "Counter"
Make it "Calculated data" and use the expression =_padnumber(counter(1),3)
OK your way back out.

lol.. really very nice. never thought about using a lib field that way.   :)
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9139
Re: Q: how to fill the NAME field with incrementing numbers?
« Reply #9 on: September 04, 2010, 07:42:46 am »

I wish it could be also done for the directory-renaming-expression
(I defined a field to compute where every file will go to but the rename tool changes the "\" with "_")
So I have to write the expression directly to the directory rule.

thanks,
Shay
Crazy how you never stop learning with this software huh?

The quoted problem exists because the rename tool knows about Windows filenaming limitations, and in windows file names, a back slash is an illegal character. The rename tool checks these things before passing them on to any expression based rules contained within your instructions.

What this means is, that if you were to set up a library field that contained a folder path you wanted to use, the rename tool replaces the backslashes with underscores, and passes this info along as gospel. If you were to then wrap that info inside a replace() function, it would reverse the underscore replacement performed by the rename tool:

replace([field containing path],_,\)

-marko
Pages: [1]   Go Up