INTERACT FORUM

Please login or register.

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

Author Topic: Do expressions work for renaming file from properties?  (Read 2882 times)

darichman

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1362
Do expressions work for renaming file from properties?
« on: June 02, 2006, 08:09:55 pm »

I posted further down about not being able to get more complex expressions to work for reorganising my file structure...

I've just tried some simple conditional expressions:
eg: If(IsEmpty([Album]), File path if TRUE, File path if FALSE)

And they aren't working for me either... Files for which [Album] is empty still end up in a "Unknown Album" folder.
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9139
Re: Do expressions work for renaming file from properties?
« Reply #1 on: June 03, 2006, 01:37:10 am »

yes, and yes, and I can't see anything wrong with the simple expression above.

I use the following for the path:

IF(IsEqual([media type],audio,1),if(isequal([album],Assorted Tracks,1),My Music\[album],if(isempty([disc #],1),My Music\[file type]\[album artist (auto)]\[Album],My Music\[file type]\[album artist (auto)]\[Album]\Disc [disc #])),IF(IsEqual([media type],image,1),IF(IsEqual([genre],album art,1),My Music\[genre],My Pictures\MC\[date (year)]\[date (month)]),Movies\[genre])

and the following for the filename :

IF(IsEqual([media type],audio,1),If(IsEqual([album artist (auto)], /(Multiple Artists/), 1),[track #] - [artist] - [name],[track #] - [name]),IF(IsEqual([media type],image,1),IF(IsEqual([genre],album art,1),[album artist (auto)] - [album] /([keywords]/) ~ [dimensions],[date (filename friendly)]),IF(IsEqual([genre],Music Video,1),[artist] - [name],[name]))

and they work a treat.

[nudge]the only glaring omission is the ability to use expressions in the base path field.[/nudge]

I can't think why it might not be working for you...

network drives?
perhaps if you were to paste the expression exactly as you're using it, there might be more clues?

-marko.

darichman

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1362
Re: Do expressions work for renaming file from properties?
« Reply #2 on: June 03, 2006, 06:37:44 am »

Thanks Marko...

The expression I'm trying to use is for photos.

Files in which either [Date (Year)] or [Album] are empty go to G:\Photos\#To Sort\[Set]

Those which have Year and Album filled go to G:\Photos\[Date (Year)]\[Album]
Those which have multiple sources (a custom [Photo (Source)] field populated go to G:\Photos\[Date (Year)]\[Album]\[Photo (Source)] 

The last one is to separate different sets that still belong to the same album

The expression I used was:
If(IsEmpty([Photo (Source)]), If(IsEmpty([Date (Year)]), If(IsEmpty([Album]), Photos\#To Sort\[Set], Photos\#To Sort\[Album]), If(IsEmpty([Album]), Photos\#To Sort\[Date (Year)], Photos\[Date (Year)]\[Album])), If(IsEmpty([Date (Year)]), If(IsEmpty([Album]), Photos\#To Sort\[Set], Photos\#To Sort\[Album]\[Photo (Source)]), If(IsEmpty([Album]), Photos\#To Sort\[Date (Year)], Photos\[Date (Year)]\[Album]\[Photo (Source)])))

The conditions I used were:
•   IF [Photo (Source)] EMPTY
            o        IF [Date (Year)] EMPTY
                       •   IF [Album] EMPTY
                                    •   Photos\#To Sort\[Set]
                       •   IF [Album] NOT EMPTY
                                    •   Photos\#To Sort\[Album]
              o        IF [Date (Year)] NOT EMPTY
                       •   IF [Album] EMPTY
                                    •   Photos\#To Sort\[Date (Year)]
                       •   If [Album] NOT EMPTY
                                    •   Photos\[Date (Year)]\[Album]

•   IF [Photo (Source)] NOT EMPTY
              o        IF [Date (Year)] EMPTY
                       •   IF [Album] EMPTY
                                    •   Photos\#To Sort\[Set]
                       •   IF [Album] NOT EMPTY
                                    •   Photos\#To Sort\[Album]\[Photo (Source)]
              o        IF [Date (Year)] NOT EMPTY
                       •   IF [Album] EMPTY
                                    •   Photos\#To Sort\[Date (Year)]
                       •   If [Album] NOT EMPTY
                                    •   Photos\[Date (Year)]\[Album]\[Photo (Source)]


I must be incredibly dense or something, because whatever expression variations I use I still get "Unknown [Field]" folders after using the expression in the "Rule" option for the file path.

*sigh* What am I doing wrong :(
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9139
Re: Do expressions work for renaming file from properties?
« Reply #3 on: June 03, 2006, 09:57:40 am »

go back to basics.

you said the simple if(isempty([album]),,) expression was not working, but it should be. If that's not working, there's no way the complex expression can be reliable if it's using similar syntax.

If you paste the full expression here, exactly as you are using it, we might be able to get somewhere. Atm, I'm wondering if it's to do with either the '#' symbol or the use of the calculated [date (year)] field.

darichman

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1362
Re: Do expressions work for renaming file from properties?
« Reply #4 on: June 04, 2006, 01:51:31 am »

Thanks again for looking into this Marko. BTW the expressions I've been using work when I use them as a calculated custom field ~ they display exactly what I want them to... It seems to only be the rename function I'm having trouble with!

I just tried...

If(IsEmpty([Album]), Photos\#To Sort\[Date (Year)], Photos\[Date (Year)]\[Album])

...on an image file with an empty album (but year was filled out).

It went to G:\Photos\[Year]\Unknown Album

The expression worked on a file for which both album and year were filled (ie file went to: G:\Photos\[Year]\[Album]

EDIT: Just tried it changing "#To Sort" to "To Sort" (to remove the #) with the same results.


EDIT 2: Ok, might be onto something. I noticed in your expressions you had a ",1" in the isempty function. So I added that in and the above [Album] expression worked ok.

So then I tried changing my more complicated one as well. But that didn't work. What do the numbers do to the expression?

I am confuzzled :(
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9139
Re: Do expressions work for renaming file from properties?
« Reply #5 on: June 04, 2006, 10:00:48 am »

Quote
What do the numbers do to the expression?
from the expression web page:
Quote
IsEmpty(...): Tests to see if a value is empty and outputs a "1" if the value is empty, and "0" if it's not empty.

    Value: the value to test
    Mode: the mode to test (optional: defaults to 0)

        0: string style, so "" is empty
        1: number style, so "" or 0 is empty

At first I left the mode switch out, figuring that empty is empty, and that string style "" would fit the bill. It didn't work.
My isempty question relates to the [disc #] field, whose data type is set to integer, and I found that adding the ,1 mode switch for a 'number style' test sorted that out.

Back to your problems...

Something has just occurred to me...
You're dealing with images here, now, have you manually emptied the [album] field for your images?
By default, MC populates the album field with the image [date] field (minus the time). I don't have a single image file in my library with an empty album field.

I need a break from my own mess of scanned images and MC images, so I'll set up a couple of quick tests here and see what happens...

brb.

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9139
Re: Do expressions work for renaming file from properties?
« Reply #6 on: June 04, 2006, 12:13:02 pm »

the following simple expression...

if(isempty([artist]),no artist,[artist])

is behaving oddly.

two image files renamed from props using the above expression (D:\My Pictures\Scanned Photos (mc)\ is in the base path)

The expression believes both files have an artist.

switching the expression to number style compare...
if(isempty([artist],1),no artist,[artist])

the expression believes neither file has an artist.

switching to isequal:
if(isequal([artist],unknown artist,1),no artist,[artist])

appears to work as expected.

Now, if my memory serves me correctly, this was how we handled empty fields in the early days of expressions, then there was a change of some kind and we were instructed to use the new IsEmpty rule. Some clarification from j.river would be useful here, thanks.

darichman, In the meantime, it looks as though you might get more success if you try changing from isempty to isequal questions.
Note that as far as isequal is concerned, the ,1 mode switch indicates that it should do a case-insensitive compare.

As a suggestion, try replacing the green part of your expression with a simple field name, [photo (source)], for example, while you get the red part working, then move on to what to do if source does not equal unknown source. Might help keep the waters less muddy.

--------------------------
and after all that palava, I found this post by Matt, made 12 months ago, that appears to suggest that what I've found is default behaviour  ::)
http://yabb.jriver.com/interact/index.php?topic=28349.0
You may need to use IsEqual([Artist], Unknown Artist) in this tool.







darichman

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1362
Re: Do expressions work for renaming file from properties?
« Reply #7 on: June 04, 2006, 07:33:45 pm »

Thankyou Marko!

I will definitely try this. Off to work now so will see if this works tonight.

I empty the album field for all photos on import (wish there was a way to turn off the way MC automatically assigns date to the album!)... but as you said it doesn't explain why artist would be behaving badly. hrm.

I was able to get isempty wot work for album if I used the 1, mode switch.
Interesting...

Also, this doesn't explain why the same expressions work fine when used as a calculated field within the library, but won't wok when used in the rename tool. I wonder, do they handle things differently? Or are images confusing matters...
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9139
Re: Do expressions work for renaming file from properties?
« Reply #8 on: June 05, 2006, 01:07:55 am »

the inference that I picked up on was that when using the rename from props tool, by the time the expression gets to check, the field is already populated with the "unknown id" entry, so the expression returns a false (not empty) result. if you force a number style check using ,1 I'm guessing the result is always a positive regardless, because there are no numbers present.

I keep the date in the album field. There are times when I find it quite useful. I use a seperate viewscheme to list those images that have been placed in specific [album]s, it's in the image group, honouring parent searches, and in step 4 I have : -[=mid([album],2,1)]=// which effectively excludes any images with a date in the album field.

-marko.

darichman

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1362
Re: Do expressions work for renaming file from properties?
« Reply #9 on: June 07, 2006, 02:46:42 am »

Hey there...

Marko: following your advice (and after a bit of my own testing), I managed to do what I want.

A heads up for anyone out there using expressions to rename your image files:

Use the if(isequal([Field],Unknown Field,1),X,Y) function when dealing with string fields
Use the if(isempty... function when using the date (year) field...

I think the fact that the isempty function doesn't work for some fields in images could be a bug?
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9139
Re: Do expressions work for renaming file from properties?
« Reply #10 on: June 07, 2006, 03:44:22 am »

Glad you got it sorted.
Have to say I did wonder if there was a bug lurking around in there...

It feels this goal was a lot harder to realise than it should have been.
If it transpires there is a bug, you'll need to keep an eye out, coz any subsequent fix will most likely break your currently working rule :D

-marko.
Pages: [1]   Go Up