Seeing as I know how some of you guys here are genius programmers (ass kiss alert!), thought I'd see if someone could help me out by writing a small application for me. As I'm not great at explaining things, this is want I'd want the app to do; 1. Search a selectable drive (including sub/folders) for .m3u files 2. Open all .m3u files found for editing, and remove any lines that start #EXT 3. After all #EXT lines have been removed, save the file(s) overwriting the original(s). TBH, although I know nothing about programming (other than a few lines of BASIC ), the searching and opening would be pretty straight forward I think. It's the editing of the files that I imagine would be a little more complex... Just incase my inability to explain has left you in the dark, here's an example of what I'd want to achieve; Original playlist file; Modified file, after running the application Anyone think this is do-able? Or am I asking way too much?
What operating system are you using? In linux or os x you could do that in a line of shellscript. Can't be assed to think through how you'd go about it but there are people on here who are a lot better at scripting than me and I'm sure they'll be able to do it for you. If you're in windows then the most reliable way I would have of doing it would be either to install CYGWIN and do it through scripting anyway, or write some bloated piece of Java, and I'm not up for that. Good luck, AH
A PHP Solution I'm not sure how practical this is, but you can do this with PHP. PHP: <? // The directory to find files in $dir = "./"; // The file extension to look for $ext = "m3u"; // The string to search for $search = "#EXT"; // For every file in the directory with the extension... foreach (glob ("{$dir}*.{$ext}") as $file) { // Open the file $fh = fopen ($file, 'r+'); // Read the file $read = fread ($fh, filesize ($file)); fclose ($fh); // Explode the file into an array $lines = explode ("\n", $read); // For each line in the file... foreach ($lines as $key => $val) { // If the line starts with the search string... if (preg_match ("/^{$search}.*/", $val)) { // Delete the line unset ($lines [$key]); } } // Save the current file $tidy = implode ("\n", $lines); $fh = fopen ($file, 'w+'); fwrite ($fh, $tidy); fclose ($fh); } ?> That will iterate through the supplied directory, find files with the given extension, and remove lines that start with the defined search string. Edit: PHP owns.
@ArtificialHero: yeah, WinXP I'm afraid. I'm not a Linux type of person (can't be bothered to learn), and the only way I'd ever run OS was if I could get it working 100% on a PC. @hacker 8991: that's fantastic! Although I've got no idea about PHP, it just searched around on Google, found a PHP editor, and converted the PHP file to an exe. Now, like I said I've got no idea when it comes to this type of thing but, the exe works but only when it's in the same folder as the .m3u files. Is it possible to have it search through all sub-folders? Or does it already do that, and it's the PHP->EXE thing that's messing things up? Maybe I should explain what it is I'm doing. Got a new phone (K800i) to use as an mp3 player, and although it supports .m3u playlists, only the old-school ones work (ie, the ones without the #EXT lines). I was hoping I could just leave this exe on the memory card of my phone, and whenever I copy new music across, just run the file to edit all the playlists. Really appreciate all the help from you guys.
Yeah, that PHP script won't search through subfolders recursively though it wouldn't be too hard to implement. I might whip up an exe in VB seeing as I really have nothing better to do at the moment.
Riggs give this a try. Let me know if there are any problems or other features you need. The program will only edit the file if there are any #EXT lines to remove otherwise it leaves it alone. That's why it tells you the number of M3Us found as well as the number edited. http://homepage.ntlworld.com/alex.spurling/M3UEditor.exe
Aha, that's bloody fantastic! Does exactly what I was asking for, and it's nice and simple. If you wanted to put an 'about' box in there somewhere, just to say who created it etc, I'll post this on a few Sony Ericsson forums (if you don't mind)? I'm sure many people will find this very useful... Thanks again to everyone that posted
So you just need the list of files, right? the #ext lines only comes when winamp (if you use winamp) have "loaded" the songname from the ID3 tag. Set winamp to only load ID3 tags when the song starts playing. problem solved. (go to the titles menu and tick the box that says "load metadata only when files are played") I THINK this should work. (unless you play the files added to the playlist ofcourse....)
Ok riggs, I added an about box. I included a link to this thread in case anyone wants to comment on it. I also fixed a couple of bugs including actually implementing the subfolders checkbox. Feel free to point your Sony Ericsson users to the url.
Whilst the problem has long been solved, it could have easily been solved in just one line of code in Windows.. Code: for /R %i IN (*.m3u) do type %i | (find /V "#EXT") > %i XP can do unix-y stuff too!