INTERACT FORUM

Please login or register.

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

Author Topic: Expression help  (Read 1887 times)

park

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2358
  • I wish I had more to say!
Expression help
« on: November 23, 2007, 05:33:49 am »

Hello,

I would like to separate all of my subtitle files from one the videos. I am trying to write an expression that says:

"Move srt,sub,idx files to "base path"\Subtitles"

Here are my lame attempts at writing an expression to achieve that, neither of which work:
if([File Type]=[idx],,[srt], Subtitles\)
if(isEqual([File Type], idx,sub,srt, 1), Subtitles\)

I am guessing that adding all those commas in the expressions is messing things up. How do I create a list of more than one file type to check against?

Thanks,
Bri
Logged

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Expression help
« Reply #1 on: November 23, 2007, 08:54:56 am »

I could help you with the If statement, but I'm not sure how to accomplish the actual move of the files in the way that you want.  First of all, though...

The way the if statement in MC's expression language works is this (from the DevZone):

Quote
If(...): Outputs different values depending on the value of the first parameter.

Test Expression: the value that gets tested
True: the value used if the test expression equals 1
False: the value used if the test expression does not equal 1

Code: [Select]
   Examples:
   If(1, 1, 0)
   If(IsMissing(), The file is missing., The file is here.)
   If(IsEqual([Artist], Abba, 1), Too embarrassing, [Artist])

One way to test multiple extensions against the [File Type] tag would be to use a nested If statements (similar to the Artist = Abba example given in the dev zone documentation but a bunch of them).  Instead of your goal, say you just wanted a column that would display YES if the file was one of those three types, and NO if it wasn't.  You could add an Advanced Expression column with this expression:

Code: [Select]
If(IsEqual([File Type], idx, 1), YES,If(IsEqual([File Type], srt, 1), YES, If(IsEqual([File Type], sub, 1), YES, NO)))
So the way that works is it tests the first IF statement, if it is TRUE, it enters "YES".  If it is false, then it evaluates the second IF statement, and then if that one is false it evaluates the third statement.  This might not be the cleanest way if you want the same results for each test, but I couldn't figure out how to do an OR comparison in the test part of the If statement.

However, how to get it to properly move the files in the way you want is beyond me (or at least beyond hung-over-from-thanksgiving-drinking-me).
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9133
Re: Expression help
« Reply #2 on: November 23, 2007, 12:14:06 pm »

Ordinarily, you would use the "Rename files from properties" tool for a job like this, but the limitations placed on this tool by the "Base Path" field make it harder than it needs to be, if not impossible.

The following should work for you...

1. Create a smart list using the following rule: [file type]=idx,srt,sub
2. You now have all of your subtitle files in a single list. Make sure it is in "details" view, not thumbnails.
3. Can you see the "Filename" column? If not, right click on a column header and pick "Filename" from the columns sub-menu.
4. Select a single file, right click on the filename field and choose rename, this will place the field into edit mode.
5. paste the following into the filename field then press enter: =[filename (path)]Subtitles\[filename (name)]
6. Happy?
7. If yes, select all files and repeat, if not, what went wrong?

-marko.

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Expression help
« Reply #3 on: November 23, 2007, 12:43:19 pm »

7. If yes, select all files and repeat, if not, what went wrong?

Marko's got the method for you.

Just one little tweak.  On this step, don't re-select the "test" file or it'll end up in ..\Subtitles\Subtitles\[Filename]
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9133
Re: Expression help
« Reply #4 on: November 23, 2007, 12:55:07 pm »

good catch glynor, cheers :)

park

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2358
  • I wish I had more to say!
Re: Expression help
« Reply #5 on: November 24, 2007, 11:50:10 pm »

Thanks for that guys.
Marko, your solution sounds the easiest, but I'd like to work an expression into my existing expression for the "rename files" tool if possible.
In that case I guess that Glynors solution of nested if statements would be best eh? I thought that I was just missing the right syntax to be able to apply an action to a list of different file types. I didnt realise that I'd need to separate each one out into it's own statement.

So now I guess my code will look like this:
Base path: \Video\
Code: [Select]
If(IsEqual([File Type], idx, 1), Subtitles\,If(IsEqual([File Type], srt, 1), Subtitles\, If(IsEqual([File Type], sub, 1), Subtitles\, NO)))

But what do I do about the "No" statement at the end. Can I just delete it? I guess that the expression needs to know what to do if nothing meets those criteria right?
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9133
Re: Expression help
« Reply #6 on: November 25, 2007, 05:37:20 am »

the no statement can be omitted. the evaluator treats it as "if no, do nothing"

if(isequal([file type],idx,1),Subtitles\,if(Isequal([file type],srt,1),Subtitles\,if(isequal([file type],sub,1),Subtitles\,)))

note that you need to keep the comma that ends the yes statement.

Are you going to use this in a 'one expression to name them all' expression for the rename from properties tool, or is it just an expression for dealing with video files and their subtitles?
 

park

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2358
  • I wish I had more to say!
Re: Expression help
« Reply #7 on: November 25, 2007, 08:15:27 am »

Thanks Marko.
Yes. This aims to be one big expression so that I can use the "rename files" tool without thinking.

At the moment it looks like this:
Quote
if(isequal([Media Type], Video, 1),
    if(isEqual([Type], TV, 1), Video\[Type]\[Genre]\[Album]\[Keywords], Video\[Type]\[Genre]\[Album])
if(isequal([Media Type], Image, 1),
    if(isEqual([Source], Personal, 1), Image\[Subject]\[Country]\[Area]\[Places], Image\[Source]\[Type]\[Keywords])
if(isequal([Media Type], Audio, 1),
    Audio\[Genre\[Album Artist (Auto)]\[Album]
if(isequal([Media Type], Data, 1),
    If(IsEqual([File Type], idx, 1), Video\Subtitles\,If(IsEqual([File Type], srt, 1), Video\Subtitles\, If(IsEqual([File Type], sub, 1), Video\Subtitles\, )))
, ))))

I havent tried it out yet. I have made a new folder called "Media"d plan to have all my files sit inside it, in appropriate "Audio", "Image", "Video", and "Subtitle" subfolders.

What do you think? I'd like to see the "if" statement added to the search wizard. I dont know how confusing it would be to use, or how hard to program, but it seems to me that a lot a people would like to do what I'm attempting to, but will never even try if they have to learn the expressions language.
Logged

park

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2358
  • I wish I had more to say!
Re: Expression help
« Reply #8 on: November 27, 2007, 09:27:37 am »

For anyone who is interested, I got my expression to work. The one above had a few errors in it.
The code below will create the following folder structure for my files:

(Audio)
Media\Audio\[Genre]\[Album Artist (Auto)]\[Album]

(My Images)
Media\Images\[Subject]\[Country]\[Area]\[Places]

(Images from other people or downloaded)
Media\Images\[Source]\[Type]\[Keywords]

(TV episodes)
Media\Video\[Type]\[Genre]\[Album]\[Keywords]

(Movies)
Media\Video\[Type]\[Genre]\[Album]

(Subtitles)
Media\Video\Subtitles

Code: [Select]
if(isEqual([Media Type], Video, 1),
    if(isEqual([Type], TV, 1), Video\[Type]\[Genre]\[Album]\[Keywords], Video\[Type]\[Genre]\[Album]),
if(isEqual([Media Type], Image, 1),
    if(isEqual([Source], Personal, 1), Images\[Subject]\[Country]\[Area]\[Places], Images\[Source]\[Type]\[Keywords]),
if(isEqual([Media Type], Audio, 1),
    Audio\[Genre\[Album Artist (Auto)]\[Album],
if(isEqual([Media Type], Data, 1),
    if(IsEqual([File Type], idx, 1), Video\Subtitles\, if(IsEqual([File Type], srt, 1), Video\Subtitles\, if(IsEqual([File Type], sub, 1), Video\Subtitles\,)))
, ))))

Or without any formatting:
Code: [Select]
if(isEqual([Media Type], Video, 1), if(isEqual([Type], TV, 1), Video\[Type]\[Genre]\[Album]\[Keywords], Video\[Type]\[Genre]\[Album]), if(isEqual([Media Type], Image, 1), if(isEqual([Source], Personal, 1), Images\[Subject]\[Country]\[Area]\[Places], Images\[Source]\[Type]\[Keywords]), if(isEqual([Media Type], Audio, 1), Audio\[Genre]\[Album Artist (Auto)]\[Album], if(isEqual([Media Type], Data, 1), if(IsEqual([File Type], idx, 1), Video\Subtitles\, if(IsEqual([File Type], srt, 1), Video\Subtitles\, if(IsEqual([File Type], sub, 1), Video\Subtitles\,))),))))
MC is in the process of renaming 25,000 files right now. Over 400gb of files.
Fingers crossed...
Logged
Pages: [1]   Go Up