INTERACT FORUM

Please login or register.

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

Author Topic: Need playlist help  (Read 9402 times)

fitbrit

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4889
Need playlist help
« on: August 17, 2016, 02:08:10 am »

Bottom line: My problem can be solved if there were a way to bulk save/export numerous playlists, whose component tracks have had their filepaths changed.

Context:
A client has 450+ playlists that were built on MediaMonkey on his desktop PC, residing on the C:\ drive.
He has since bought a dedicated media PC. He wants all the playlists to show up correctly in MC 22, on the F:\ drive which is physically connected to his media PC, but is also mapped as F on his desktop PC. All the music files have been COPIED from the C:\ drive to the F:\drive.

I was able to import the playlists on his desktop machine. They pointed to the originals on the C:\ drive. Using "RMC files" I was able to select all the tracks on the playlists and refer them to the F:\ drive copies. Unfortunately, this does not automatically update/resave the playlists. The actual M3U files on the F drive are not modified when one changes the paths of the files indexed in the playlist. So the playlists all playback fine on the desktop with the modified paths, but show up as empty on the media PC.
Exporting each playlist to mpl, one at a time, is not an option, but it does work. If I select all the playlists in one go, the only right-click option is to delete them all. It would be excellent if the option to export them all in bulk were an option too.

Can anyone else think of another way to solve this problem? It's late here, so apologies if it's not been explained clearly.
Logged

Spike1000

  • Citizen of the Universe
  • *****
  • Posts: 641
Re: Need playlist help
« Reply #1 on: August 17, 2016, 06:25:18 am »

Does the problem distil down to replacing C:\Music with F:\Music (or whatever) in 450 text (m3u) files?

If that's the case it could be done programatically with a simple script and one of many text processing tools.

If you give me an example I can knock something up for you (if nobody comes up with a neater trick).

Spike

JimH

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 72549
  • Where did I put my teeth?
Re: Need playlist help
« Reply #2 on: August 17, 2016, 07:13:20 am »

Does the problem distil down to replacing C:\Music with F:\Music (or whatever) in 450 text (m3u) files?
MC has a Find and Replace tool that should be able to do that.
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Need playlist help
« Reply #3 on: August 17, 2016, 07:15:07 am »

I agree with Spike.  A perl one liner would look something like this.  (Untested):

perl -pi -e 's/^C:\\/F:\\/' *.m3u

Brian.
Logged

fitbrit

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4889
Re: Need playlist help
« Reply #4 on: August 17, 2016, 07:57:05 am »

MC has a Find and Replace tool that should be able to do that.

Hi Jim
Since it's in the filename, I've successfully updated the location using find/replace within Rename, Move and Copy Files. The problem is that that does not automatically update the M3U files, only the tags within MC. You have to manually export the playlist for the location in the M3U, or other playlist file, to be updated. And you can only export one playlist at a time.
Logged

fitbrit

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4889
Re: Need playlist help
« Reply #5 on: August 17, 2016, 08:04:07 am »

Thanks, Spike1000 and blgentry. That is indeed something that would work - a script to make the changes to the paths in each M3U file. I tried to open a m3u in WordPad to see if I could see the format/syntax of the file, and maybe do a manual find/replace on one to get a feel for the filetype. It did not open first time, so I abandoned the idea.

The actual change is from something like:

C:\Copy of K\Copy of Olive\Audiophile\

to

F:\Media\CD Music\
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Need playlist help
« Reply #6 on: August 17, 2016, 08:19:09 am »

I just tested this and it works for my test cases:

Code: [Select]
perl -pi -e 's/^C:\\Copy of K\\Copy of Olive\\Audiophile\\/F:\\Media\\CD Music\\/' *.m3u
If you need some help with this offline, PM me and we'll see if we can do some screen sharing or something.

Brian.
Logged

fitbrit

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4889
Re: Need playlist help
« Reply #7 on: August 17, 2016, 08:33:35 am »

Thanks very much, Brian. So that I am absolutely clear:

I save the script in a .bat file using a text editor, in the same folder as all the M3U files (which reside on the F drive too, now).
Then, when I run the script, it will go inside each m3u and change the text strings as noted. I will change the script to match the exact file paths, of course.
And then the updted m3us will be saved.

Is that right?
Sorry for my inexperience with scripts.
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Need playlist help
« Reply #8 on: August 17, 2016, 09:04:23 am »

Batch file?  Not sure.  But you can run it from the command line easily.  I tested it on a Mac, but it should be very close, as Perl is very cross platform compatible. 

Yes, you run it from the same directory where the M3U files are.  It *changes* each file, as you have said.  So you'll want to make backups of the files first, then test and verify.  Then run it against all of them at once.

Brian.
Logged

fitbrit

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4889
Re: Need playlist help
« Reply #9 on: August 17, 2016, 09:34:06 am »

Thanks a lot! Ok I think I know what to do.

The files are already backed up - we made a copy of them all in the new location that was being monitored by auto-import.
Logged

Spike1000

  • Citizen of the Universe
  • *****
  • Posts: 641
Re: Need playlist help
« Reply #10 on: August 17, 2016, 10:04:22 am »

You'll also need a copy of Perl on your PC as it's not built in. ActivePerl (community edition) by Active State is free and is easy to install and then uninstall on Windows (when you're finished). A bit of a sledge hammer to crack a nut (other smaller distributions may be available) but it works.

Spike

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Need playlist help
« Reply #11 on: August 17, 2016, 10:08:30 am »

Good point Spike.  I haven't used Perl on a Windows box in quite some time, but ActiveState Perl worked fine way back (8 years ago or so).  MrC (who knows more than a little about Perl) recommends Strawberry Perl for use with his MCUtils package:

http://strawberryperl.com/

I have no experience with it.  Just passing on (presumably) sage advice.

Brian.
Logged

fitbrit

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4889
Re: Need playlist help
« Reply #12 on: August 17, 2016, 10:19:50 am »

Oh, I didn't think of that. Thanks to you both again!
Logged

fitbrit

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4889
Re: Need playlist help
« Reply #13 on: August 18, 2016, 03:21:50 pm »

I tried this script as it has the correct find and replace filepaths:
In the C:\Playlists c> directory.

Code: [Select]
perl -pi -e 's/^C:\\Copy of K\\Copy of Olive\\/F:\\Media\\CD Music\\/' *.m3u
But I get this message in response:

Code: [Select]
Can't find string terminator "'" anywhere before EOF at -e line 1.
Logged

fitbrit

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4889
Re: Need playlist help
« Reply #14 on: August 18, 2016, 04:02:50 pm »

If I try:
Code: [Select]
perl -pi -e 's/^C:\\/F:\\/' *.m3u
I get:
Code: [Select]
Can't open *.m3u: Invalid argument.So that's progress at least. Somehow the "'" isn't lost in the simpler version that only changes the directory path from C to F.

And if I try to choose a specific name for an m3u:
Code: [Select]
perl -pi -e 's/^C:\\/F:\\/' Rheingold.m3u
I get:
Code: [Select]
Can't do inplace edit without backup.
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Need playlist help
« Reply #15 on: August 18, 2016, 04:21:40 pm »

Uggggh.  Darned Windows.

I just tried this in a VM and got the same error.  Apparently the CMD.exe shell interprets pretty much everything differently than a unix style shell (as we have under Mac OS X and all versions of Unix).

I hate to advise you to download yet more software, but I *have* tested it this time.  Cygwin seems to work just fine for this.  Cygwin is a unix like environment that runs in a terminal window under Windows.

https://cygwin.com/install.html

Presuming you want to do this, after you fire up the Cygwin terminal, you'll be in a "virtual directory" which does you no good.  To get to your C drive, type:

cd /cygdrive/c

Then you can navigate as normal to where you need to go.  I was going to tell you to run the original command I gave you, but Windows has one more trick for us:  It doesn't like doing perl in place edits without backup files.  So, modify the command to this:

Code: [Select]
perl -pi.bak -e 's/^C:\\Copy of K\\Copy of Olive\\/F:\\Media\\CD Music\\/' *.m3u
This will create files ending in ".bak", which are the original, unaltered files.  You can remove these when you're done if you don't want them.  The m3us will be modified "in place" and should work correctly.

Sorry for the trouble.  I really should test this stuff on Windows first I guess.

Brian.
Logged

fitbrit

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4889
Re: Need playlist help
« Reply #16 on: August 18, 2016, 04:51:04 pm »

Thanks SO MUCH, Brian.

I should also have tested this on my own machine before that of a client's. I'll do what you suggest and run some test cases on my own PC first and see. I'll then do a trial run on 5 of the client's playlists, and then do all the remaining ones afterwards.

Still, it would not be necessary if one could use standard view to export, update or rewrite, multiple playlists at the same time.
Thanks for all your help.

Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Need playlist help
« Reply #17 on: August 18, 2016, 04:54:54 pm »

You're welcome. 

Personally, I'd transfer all of the playlists to my own machine (maybe in a zip file?).  Then work on them without the client "watching", get them perfect, and then transfer them back. 

Good luck and let me know if I can help further.

Brian.
Logged

fitbrit

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4889
Re: Need playlist help
« Reply #18 on: August 18, 2016, 05:18:29 pm »

Not a bad idea at all, but I don't want to have to install yet another piece of software,unless zipping is a built-in function of Windows. I guess I could use dropbox and then uninstall it after.
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Need playlist help
« Reply #19 on: August 18, 2016, 06:52:54 pm »

Personally I find the free Notepad++ an excellent tool for such editing.

It even supports PCRE (Perl Compatible Regular Expression) Search/Replace, so you should be able to use Brian's regex expression without installing Perl on your system. But it has built in functions that will do what you want.

I haven't used it on multiple files at once, but it has a "Search>Find in Files" function that will find and replace a text string in a directory full of files, and its sub-directories, I believe.

I like that visual nature of testing the Find and Replace function, and once I am happy, can just click "Replace All" or "Replace in Files" using the above function.

PS: Sorry Brian. I know Regex is your passion.  8)
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

fitbrit

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4889
Re: Need playlist help
« Reply #20 on: August 19, 2016, 11:09:28 pm »

Thank you too, Roderick. I think I now have enough options to solve this.
Logged

milehigh

  • Regular Member
  • World Citizen
  • ***
  • Posts: 109
  • nothing more to say...
Re: Need playlist help
« Reply #21 on: August 22, 2016, 01:15:33 pm »

why recreate the wheel??  :)

Try this little program that has a nice interface - can find and replace path's within files.  Works great.


https://findandreplace.codeplex.com/
Logged

fitbrit

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4889
Re: Need playlist help
« Reply #22 on: August 27, 2016, 02:38:12 pm »

why recreate the wheel??  :)

Try this little program that has a nice interface - can find and replace path's within files.  Works great.


https://findandreplace.codeplex.com/

This was the first thing I tried, and it was amazingly easy. Thanks for this recommendation.
And thanks to everyone for their input. The changes have been made, and I have to now move the adjusted playlists to the user's audio PC to verify all is as it should be. As far as my question was concerned, though, the problem is solved and I can take it from here.
Logged
Pages: [1]   Go Up