INTERACT FORUM

Please login or register.

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

Author Topic: regex with find and replace?  (Read 3459 times)

Bill Kearney

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 373
regex with find and replace?
« on: May 19, 2006, 08:16:55 am »

Is there a way to use regexes with find and replace?  As in, I want to flop the name on some tracks.  "Artist - Track Name" to at least "Track Name - Artist".  Ideally I'd love to pull out the first part and dump it over into the Artist Name column.

Or is there some handy external program I could use to do this?
Logged

Bill Kearney

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 373
Odd column movement
« Reply #1 on: May 19, 2006, 09:20:48 am »

Not sure if this is a 'bug' per-se, but it's certainly a little annoying.

If I have a track named "artist - track' and I edit the name to just the last half (track) and then hit tab to move to the artist column, in-between the rename and the tab the column re-sorts itself.  Which means when the tab moves to the next column it's moving to the WRONG track.   I'm sure this has everything to do with what columns are being sorted.  But it's a serious UI problem in that the tab movement really isn't valid. 

The fix would be to STAY with the track and move to the next column for THAT track, not the one at that place in the displayed list.  Or, at the very least, invalidate the tab action such that it didn't drop them into an edit box for a now completely different row.

MC's abilities for doing track edits is really great, I know of nothing better, but it's little UI things like this that make it a bit harder to use that necessary. 

That and PLEASE GIVE US A WAY TO TELL THE ACTION BOX TO STOP RAISING ITSELF!  Yes, shouting (again, and again...)  I hate that damned box and have NO USE FOR IT.  Give me an option to cripple it's tendency to pop itself up all the danged time!
Logged

hit_ny

  • Citizen of the Universe
  • *****
  • Posts: 3310
  • nothing more to say...
Re: regex with find and replace?
« Reply #2 on: May 19, 2006, 03:03:07 pm »

Is there a way to use regexes with find and replace?  As in, I want to flop the name on some tracks.  "Artist - Track Name" to at least "Track Name - Artist".  Ideally I'd love to pull out the first part and dump it over into the Artist Name column.
If you can make a list of those tracks then you could use Rename Files from properties and specify [Name] - [Artist] as the template.
Logged

Bill Kearney

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 373
Re: regex with find and replace?
« Reply #3 on: May 19, 2006, 03:29:00 pm »

Rename files would depend on the fields already being present, would it not?  The artist field is empty.  The track name contains the 'artist - name' string.  So renaming the files wouldn't exactly work, not to mention it's not the files I need (or want) to rename.  I'm looking to populate the 'artist' field based on a substring of the track name. 

However you did trigger a thought, the filename does contain the information in a reasonably consistent format.  I can use the Library->File properties from filename function.  Is there a 'correct' way to ignore part of the filename string?
Logged

Alex B

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 10121
  • The Cosmic Bird
Re: regex with find and replace?
« Reply #4 on: May 19, 2006, 04:07:35 pm »

A workaround:

1. Make a new library field named as Filename Backup.

2. Use the Fill Properties From Filename tool:
Directories: untick / Filename: tick / Filename Rule: [Filename Backup]

3. Use the Rename Files From Properties tool:
Directories: untick / Filename: tick / Filename Rule: [Name]

4. Use the Fill Properties From Filename tool:
Directories: untick / Filename: tick / Filename Rule: [Artist] - [Name]

5. Use the Rename Files From Properties tool:
Directories: untick / Filename: tick / Filename Rule: [Filename Backup]
Logged
The Cosmic Bird - a triple merger of galaxies: http://eso.org/public/news/eso0755

Bill Kearney

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 373
Re: regex with find and replace?
« Reply #5 on: May 19, 2006, 06:00:18 pm »

I could also have done it with XSLT on the XML export, but there doesn't appear to be an XML import function.
Logged

hit_ny

  • Citizen of the Universe
  • *****
  • Posts: 3310
  • nothing more to say...
Re: Odd column movement
« Reply #6 on: May 19, 2006, 06:06:38 pm »

That and PLEASE GIVE US A WAY TO TELL THE ACTION BOX TO STOP RAISING ITSELF!  Yes, shouting (again, and again...)  I hate that damned box and have NO USE FOR IT.  Give me an option to cripple it's tendency to pop itself up all the danged time!
Lol, this is hilarious.

Did it ever strike you to dbl click the vertical grabber, which slides it to the left very conveniently hiding that Action Box that you dislike so much. Allowing you more screen estate to do tag edits as well i might add.
Logged

Alex B

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 10121
  • The Cosmic Bird
Re: regex with find and replace?
« Reply #7 on: May 19, 2006, 06:16:39 pm »

I could also have done it with XSLT on the XML export, but there doesn't appear to be an XML import function.

The MPL playlist format is the same as XML export uses. You can change the .xml extension to .mpl. However, MPL import does not update data (at least it didn't last time I tried it). It can only import new files, so you need to remove the files from the library first.

You can export a playlist in MPL format, delete only the included files from the library (shift+delete in a playlist), fix the MPL file and import it.

Though, I think the workaround I explained is easier and faster.
Logged
The Cosmic Bird - a triple merger of galaxies: http://eso.org/public/news/eso0755

EpF

  • Citizen of the Universe
  • *****
  • Posts: 649
Re: regex with find and replace?
« Reply #8 on: May 19, 2006, 06:40:07 pm »

Is there a 'correct' way to ignore part of the filename string?

As far as I can remember (it's been a while since I did it), if the filename is '01 - David Bowie - Live - Changes.mp3', you can use '[track #] - [artist] - [] - [name]' in fill props from filename to filter out 'Live' in this example.

Bill Kearney

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 373
Re: regex with find and replace?
« Reply #9 on: May 20, 2006, 07:13:21 am »

Hmm, what's with the renaming of files as (1).mp3?  It seems that when I renamed the files from having use a drive letter (M:\) to a UNC path (\\servername\share) it renamed the files even though the location was the same.  The M:\ drive was pointed to that UNC share.  Ok, that was unexpected but I can understand why. 

Now, how do I rename them back again?  That is, replace the " (1).mp3" with just ".mp3"?  The library find and replace doesn't seem to actually be doing it.  I created a smartlist that selects Filename(path) = " /(1/).mp3] and that shows them properly.  When I select a couple of them, say 5, and use the Library Tools->Find and Replace and find " (1).mp3" and replace it with ".mp3)" I get the dialog box that it says it'll do it the 5 times.  But the filenames DON'T CHANGE!  What gives?

Something's really strange here.  I selected a track, used Find and Replace on the "Filename (name)" field and changed "(1)" to an empty string.  It did it.  But this leaves the extension as " .mp3" instead of just ".mp3".  So I told it to F&R the " .mp3" with ".mp3" and IT PUT THE OLD " (1).mp3" extension back on it!  WTF is THAT about?

Find and Replace does not seem to be working properly, at least not for filenames.
Logged

Bill Kearney

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 373
Re: regex with find and replace?
« Reply #10 on: May 20, 2006, 07:26:51 am »

Ugh, and there's no way to find " (1).mp3" and replace it with just ".mp3".  MC says it did it but it DID NOT.  That is, selected a track whose filename was "04 Clash - Rock the Casbah (1).mp3" and then right-click Library Tools->Find and Replace.  Selected the "Filename (name)" checkbox and put " (1).mp3" into the Find what: box (without the quotes) and then put ".mp3" in the Replace: box.  A dialog popped up telling me ' (1).mp3' was replaced 1 time(s) with '.mp3'.  But the list still shows it with the (1).mp3 in it!  And the filename on disk didn't change.  Now, if I repeat those steps but change the find text to just "(1).mp3", leaving out the leading space, it renames it.  Arrrrrrrrggghh!  That's just frustrating.

And to make things even worse, if I F&R from " (1).mp3" to "(2).mp3" it'll work.  But if I then use F&R to change from "(2).mp3" to ".mp3" it changes it to " (1).mp3" again!   

Something's screwy.
Logged

hit_ny

  • Citizen of the Universe
  • *****
  • Posts: 3310
  • nothing more to say...
Re: regex with find and replace?
« Reply #11 on: May 20, 2006, 07:34:19 am »

The (1).mp3 is the result of a clash with MC's cache. This usually happens if you are in the tree looking at filenames then proceed to change fielnames or its path. MC remembers the file (from its cache) and thinks it already exists so it creates the new path with the (1) appended to the end.

whenever you see filenames being renamed as such, do Undo. Restart MC (which clears the cache) and then you can rename as you like. one tip i would share here is add files for modification to Playing Now and make the changes there. For some reason doing this from the tree causes the problem mentioned above but doing it from PN after a restart does not.

I'm not aware of a way to undo the (1).mp3, its bitten me when moving cue files. Only way i know is to remove the album from MC and reimport it. If you do that you lose any meta-data that was not saved in the files. SO before removing from MC, you have to save to Export to MPL, remove the (1)'s in a text editor, then delete the files from MC and then re-import back to MC from that MPL.

I'd agree the (1).mp3 is a pain. Would have chased this up over a yr ago when i noticed it in 11.0 but was unable to reproduce it consistantly, also was not sure whether it was cue related only. Just was extra vigilant to catch it happening whenever doing a rename path or move.
Logged

Bill Kearney

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 373
Re: regex with find and replace?
« Reply #12 on: May 20, 2006, 10:57:44 am »

Grrrrr, I can't use 'rename from properties' because the track number would lose a leading zero on the single digit tracks (1,2,3 = 01,02,03).  This would screw up any file system sorting. 

Ugh, it's just a complete mess, MC11 renamed my files and now it won't rename them back again without that danged (1) stuffed in there.  This is VERY aggravating.   And it doesn't help that I'm trying to use all this to get a bunch of stuff ripped to load onto my iPod for a week's trip to Spain, leaving today. 
Logged

Alex B

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 10121
  • The Cosmic Bird
Re: regex with find and replace?
« Reply #13 on: May 20, 2006, 11:01:29 am »

MC uses leading zeros when it writes the track numbers 1-9 to the filenames.
Logged
The Cosmic Bird - a triple merger of galaxies: http://eso.org/public/news/eso0755

Alex B

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 10121
  • The Cosmic Bird
Re: regex with find and replace?
« Reply #14 on: May 20, 2006, 11:20:04 am »

You could do the steps 1 and 2 from my workaround for copying the current filename to a separate field:

1. Make a new library field named as Filename Backup.

2. Use the Fill Properties From Filename tool:
Directories: untick / Filename: tick / Filename Rule: [Filename Backup]

After the names are copied to the "Filename Backup" field you could fix the copied names with Find and Replace, give the files totally different temporary filenames (for getting rid of the (1) for good) and then do this:

Quote
5. Use the Rename Files From Properties tool:
Directories: untick / Filename: tick / Filename Rule: [Filename Backup]
Logged
The Cosmic Bird - a triple merger of galaxies: http://eso.org/public/news/eso0755

Bill Kearney

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 373
Re: regex with find and replace?
« Reply #15 on: May 20, 2006, 11:37:09 am »

Oh for pity's sake, that made it WORSE.  I copied Filename(name) into the new Filename Backup column, worked fine.  I replaced the (1) with an empty string.  That likewise worked fine.  So I told it to rename from properties.  It renamed the file using the Filename Backup column and THEN APPENDED .mp3 onto it!  So now the files end in '.mp3.mp3'.   Criminy this is mess.

Oh, and get this, if I take OUT the .mp3 from the Filename Backup column and do the rename again, guess what?  The damned (1) gets inserted AGAIN!    Whoever wrote the file I/O routines for this needs a trip to the woodshed...
Logged

Bill Kearney

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 373
Re: regex with find and replace?
« Reply #16 on: May 20, 2006, 12:08:45 pm »

So, in what file is MC keeping track of things like this?  What cache can I possibly clear or delete that'll help cure it of it's insistence on that (1) getting stuffed back into the name?

I did turn on some logging and when it tries renaming a file it's showing lines like this:

0033218: Database: CTagSaveHelper::SubmitFile: Start
0033218: Database: CTagSaveHelper::SubmitFile: Submitting: \\t2\home\media\mp3\music\Various Artists\Roadhouse Blues\Various Artists - 09 - Hip Shakin' - Roadhouse Blues (1).mp3
0033218: Database: CTagSaveHelper::SubmitFile: File not taggable
0033218: Database: CTagSaveHelper::SubmitFile: Finish (0 ms)

It's not telling me WHY it's not taggable but at least I can see it throwing the error.  The full pathname is only 119 characters, so that shouldn't be it.  The attributes on the files, and the security settings are clear such that this user can do whatever it needs to the entire folder.  I can manually rename that file just fine using the explorer, as the currently logged in user.  I tried removing All Tags from the tracks and that didn't help (putting the tags back DID work).

The good part is I've managed to fight my way through it and have cleaned up all but about 30 tracks.  Through quitting MC, reloading it, renaming from properties both from the Filename Backup field and from individual ones.  MC seems to have some sort of hang-up on these last few files.  But these few are a lot less than the 1200 at the start of this.

And I'm gettin' the hairy eyeball from the wife, so I gotta go pack for our 7pm departure...  Thanks Alex, your tips helped.
Logged

Alex B

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 10121
  • The Cosmic Bird
Re: regex with find and replace?
« Reply #17 on: May 20, 2006, 12:14:19 pm »

Oh for pity's sake, that made it WORSE. I copied Filename(name) into the new Filename Backup column, worked fine. I replaced the (1) with an empty string. That likewise worked fine. So I told it to rename from properties. It renamed the file using the Filename Backup column and THEN APPENDED .mp3 onto it! So now the files end in '.mp3.mp3'. Criminy this is mess.

Oops. That's exactly why I instructed to use the "Fill Properties From Filename" tool, not the "Move/Copy Fields" tool. I should have explained that too.

Quote
Oh, and get this, if I take OUT the .mp3 from the Filename Backup column and do the rename again, guess what? The damned (1) gets inserted AGAIN! Whoever wrote the file I/O routines for this needs a trip to the woodshed...

I was afraid of that would happen. That's why I wrote this: "give the files totally different temporary filenames (for getting rid of the (1) for good)". You could try any arbitrary rule that makes completely different filenames.

I have once struggled with the (1) phenomena too. It was several months ago, but if I recall correctly changing the folder name reset the odd behavior and after that it was possible to just remove the (1) parts from the filenames.
Logged
The Cosmic Bird - a triple merger of galaxies: http://eso.org/public/news/eso0755

Bill Kearney

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 373
Re: regex with find and replace?
« Reply #18 on: May 20, 2006, 12:58:38 pm »

Filling from filename wouldn't have worked as the filenames weren't consistent enough.  I'm under the gun, time-wise, so I wanted to avoid having MC reload a whole bunch of stuff.  By the time I figured out it's some sort of really oddball bug I supposed I could've done that.  Grrr, gimme my two hours back....  ah well.

Logged

IlPadrino

  • MC Beta Team
  • Galactic Citizen
  • *****
  • Posts: 496
Re: regex with find and replace?
« Reply #19 on: May 21, 2006, 12:25:18 pm »

I could also have done it with XSLT on the XML export, but there doesn't appear to be an XML import function.

It's been talked about a lot in the past...  I don't think JRiver ever got the value of this.  Scott_r made a nice XML export plugin but didn't get around to doing an import.  As mentioned already, you can import if you delete the media item from the library, but that can be a dangerous process.

It would be great to have a real "import" that lets you merge chosen fields. 
Logged

Alex B

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 10121
  • The Cosmic Bird
Re: regex with find and replace?
« Reply #20 on: May 21, 2006, 02:02:54 pm »

Has anyone tried KingSparta's new "Data Importer" plugin?

http://yabb.jriver.com/interact/index.php?topic=33873.0
Logged
The Cosmic Bird - a triple merger of galaxies: http://eso.org/public/news/eso0755
Pages: [1]   Go Up