PDA

View Full Version : Simple problem (newbie alert)



baddog8it
02-16-2013, 07:06 PM
A relatively simple macro needed (I think).

Trying to modify an m3u playlist text file for compatibility between my player and the program that manages my files.

(I've spent countless hundreds of hours looking for a program that really does what I want - should have just dedicated that time to learning and writing a program to do what I need).

Below is what a typical text file might contain:
/D/ArtistWhoseNameBeginsWithD/SongName0001.mp3
/E/ArtistWhoseNameBeginsWithE/SongName0002.mp3
/J/ArtistWhoseNameBeginsWithJ/SongName0003.mp3
/Z/ArtistWhoseNameBeginsWithZ/SongName0999.mp3


This is a plain text file, but I think that using VBA in WORD my be my best solution.


The file is a plain text file. Each line is a path to a song on my external hard drive (my mp3 player). There are no other lines of text - every line in the file represents a song. Number of lines could be anywhere from one to infinity.

My mp3 player needs the file in a format without a drive letter and colon in the file path, while the program for managing my collection requires the drive letter. I suppose the drive letter my change, but it seems to stay consistently as 'I:'.
I:/D/ArtistWhoseNameBeginsWithD/SongName0001.mp3
I:/E/ArtistWhoseNameBeginsWithE/SongName0002.mp3
I:/J/ArtistWhoseNameBeginsWithJ/SongName0003.mp3
I:/Z/ArtistWhoseNameBeginsWithZ/SongName0999.mp3


I have the need for two macros - one to add the 'I:' and one to remove the 'I:' from each line of text.


I will take the file in the players required format (without drive letter), convert it to add the drive letter. I can then import it into my collection management program, do any required manipulation, etc. When done I can export it. I will then have to strip out the drive letter so that my player can read it.


I've searched various forums, but haven't yet found any solution(s) that that I can make fit my particular situation.


Nothing fancy needed. I'll be happy to manually do all the file management (open each file, initiate the macro, save as, etc) - just need a simple loop to cover each line of the text file.


Thanks in advance,
VBA newbie

baddog8it
02-17-2013, 12:53 AM
The search is off. Found a solution in Python that works quite well. We can call this one closed.

macropod
02-17-2013, 04:37 AM
You can do this in Word without a macro.

To add the 'I:', use a wildcard Find/Replace, where:
Find = (\/[A-Z]\/)
Replace = I:^&

To delete the 'I:', use an ordinary (or wildcard) Find/Replace, where:
Find = I:
Replace = nothing