Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Creating a playlist with REACT (Read 5816 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Creating a playlist with REACT

I guess that you could just use ECHO commands in your config to append to a playlist, e.g.:

Code: [Select]
ECHO $cdartist$ - $album$ [$date$]\$track$ - $title$.mp3>>@OutRoot@\Music\MP3\Playlists\$cdartist$ - $album$.m3u

You may have to escape some characters though, otherwise ampersands (for example) will cause problems.  Certainly a possibility though.


Thanks, I did not realise the "#" was just a comment field in the m3u file.

I tried adding your echo command between "PushD" and "PopD" as I thought it was a loop so all I got was a playlist file in the correct place with only 1 file in it. (I use F10/image).

I also tried this...

Code: [Select]
DIR /B *.flac >> temp.txt
FOR %%f IN (temp.txt) DO (ECHO ..\$cdartist$ - $album$ [$year$]\%%f>>"..\++Playlists\$cdartist$ - $album$ [$year$].m3u")


...but it does not want to loop through the contents of the temp file but rather sees it as a literal.

It produces a file with only one entry.

"..\Enya - The Memory Of Trees [1995]\temp.txt"

The temp.txt contains.

Code: [Select]
01 - The Memory Of Trees.flac
02 - Anywhere Is.flac
03 - Pax Deorum.flac
04 - Athair Ar Neamh.flac
05 - From Where I Am.flac
06 - China Roses.flac
07 - Hope Has A Place.flac
08 - Tea-House Moon.flac
09 - Once You Had Gold.flac
10 - La Sonadora.flac
11 - On My Way Home.flac


Any ideas?

Just in case you're wondering, I had to add the "++" to the playlist directory in order to get it to be the top most directory. I do not feel like scrolling all the way to "P" to get to the playlist. It's possible that there is an better way, but the "++" should work.

Thanks again for the help.

Regards
Paul

Creating a playlist with REACT

Reply #1
Try:

Code: [Select]
FOR /F "tokens=* delims=" %%f IN (temp.txt) DO (ECHO ..\$cdartist$ - $album$ [$year$]\%%f>>"..\++Playlists\$cdartist$ - $album$ [$year$].m3u")

I believe that is the right syntax to process temp.txt (I haven't examined the ECHO code to see if that is correct).
I'm on a horse.

Creating a playlist with REACT

Reply #2
Try:

Code: [Select]
FOR /F "tokens=* delims=" %%f IN (temp.txt) DO (ECHO ..\$cdartist$ - $album$ [$year$]\%%f>>"..\++Playlists\$cdartist$ - $album$ [$year$].m3u")

I believe that is the right syntax to process temp.txt (I haven't examined the ECHO code to see if that is correct).


Thanks this worked.

I only tested my syntax in a bat file which seemed to work.

Regards
Paul

Creating a playlist with REACT

Reply #3
Good news.

Just remember that some characters - ampersand being a prime example - will cause you problems.

I'm not sure if you can surround the path in double quotes in the playlist file, but that might be the easiest solution. 

[code]ECHO "..\$cdartist$ - $album$ [$year$]\%%f">>"..\++Playlists\$cdartist$ - $album$ [$year$].m3u"/code]
I'm on a horse.

Creating a playlist with REACT

Reply #4
Just remember that some characters - ampersand being a prime example - will cause you problems.

I'm not sure if you can surround the path in double quotes in the playlist file, but that might be the easiest solution. 

[code]ECHO "..\$cdartist$ - $album$ [$year$]\%%f">>"..\++Playlists\$cdartist$ - $album$ [$year$].m3u"/code]


Adding quotes produces a file with quotes :-/

Would putting it all in a single variable not help?

When you're testing like this, is there a way to execute the image.cfg file without having to rip the entire cd again?

Anyway, thank you for all the help so far. I think I got the mechanics of REACT sorted to get the result I was looking for. (Well, at least for the bulk of my collection.)

Now it's just the replaygain monster I need to tame. Is there is specific thread that I must post for rg advice?

Regards
Paul

Creating a playlist with REACT

Reply #5
Adding quotes produces a file with quotes :-/
I didn't know whether that was acceptable syntax.  I've quickly tested in foobar and it appears not.

Would putting it all in a single variable not help?
I don't really know what you mean, give it a try!

When you're testing like this, is there a way to execute the image.cfg file without having to rip the entire cd again?
Not sure.  I tend to test using a small CD image mounted on a virtual drive (Nero or Virtual CloneDrive).  Thinking about it, I did add the ability to call REACT on the command line passing it the path to a cuesheet.  If you have the WAVE , CUE and LOG files created by EAC you may be able to do it this way.

Now it's just the replaygain monster I need to tame. Is there is specific thread that I must post for rg advice?
If it's REACT-specific either the REACT behemoth thread or a new thread in "CD Hardware/Software".  If it is general RG questions then a new thread in "General Audio", or check the wiki.

One other thing that may be of use:

If you check my CREATE-M3U.BAT, which is linked to from the REACT:Creating A Playlist wiki article, you will see that I do this to process the filename:

Code: [Select]
REM Escape ampersand and caret
SET tmpString="%~nx1"
SET tmpString=%tmpString:^=^^%
SET tmpString=%tmpString:&=^^^&%
REM Remove quotes
SET tmpString=%tmpString:"=%
REM Write filename to playlist
ECHO %tmpString%>>"%~dp1\%~2"


If you amended the first line to:

Code: [Select]
SET tmpString="..\$cdartist$ - $album$ [$year$]\%%f"

.. and the last to:
Code: [Select]
ECHO %tmpString%>>"..\++Playlists\$cdartist$ - $album$ [$year$].m3u"

.. that could help.
I'm on a horse.

Creating a playlist with REACT

Reply #6
Did we just loose a few posts?

Anyway, to recap.

Code: [Select]
REM ** Create playlist in (flac) playlist directory
DIR /B *.flac >> temp.txt
FOR /F "tokens=* delims=" %%f IN (temp.txt) DO (ECHO ..\$cdartist$ - $album$ [$year$]\%%f>>"..\++Playlists\$cdartist$ - $album$ [$year$].m3u")
DEL temp.txt


Does the trick. However, it might not work when name contain "&" for example.

Adding quotes to the line to echo simply insert quotes into the file which means it's no longer an valid playlist. Not sure if this can be catered for?

I'm happy with the setup now as it would work for 90% (or possibly more) of my collection.

Then is there is way to execute the REACT-image.cfg file without having to rip/create all the files again, assuming of course that I did not delete required the files.

Thanks
Paul

Creating a playlist with REACT

Reply #7
I guess you didn't see your PM.
I'm on a horse.

Creating a playlist with REACT

Reply #8
I guess you didn't see your PM.


Yes, sorry about that... You could have just deleted the message(s) if you want.

Your "tempstring" suggestion above is what I meant with using a single variable. I'll give it a bash.

As for calling REACT from the command line, do you mean I can simply do the following?

Code: [Select]
cd C:\"Program Files"\React2
REACT2 C:\"Music (EAC)"\"Enya - The Memory of Trees [1991].cue"


All the files, wav, 5 cue files and jpg are still in this directory.

Regards
Paul

Creating a playlist with REACT

Reply #9
That's the idea.  The cue will have to point correctly to the WAVE and the log needs to be correctly named (as per EAC original).  I'm assuming that's the original image cuesheet.

I implemented it, tested it briefly and forgot about it, so I can't vouch too strongly for it.  All the code does is use the details in the cuesheet to create the parameters required to call REACT normally.  In fact, I think it may actually just create the parameters and call another instance of REACT with those parameters before exiting.  I think.
I'm on a horse.

Creating a playlist with REACT

Reply #10
That's the idea.  The cue will have to point correctly to the WAVE and the log needs to be correctly named (as per EAC original).  I'm assuming that's the original image cuesheet.

I implemented it, tested it briefly and forgot about it, so I can't vouch too strongly for it.  All the code does is use the details in the cuesheet to create the parameters required to call REACT normally.  In fact, I think it may actually just create the parameters and call another instance of REACT with those parameters before exiting.  I think.


Calling REACT from the command line, works just fine.

I wish I knew about this a week ago already ;-) The other thing I also wish I realised sooner is that I should switch off the (additional) Ogg & MP3 encoding while I'm testing ;-)

The trick is to of course run in Debug mode (Debug=1) at least once as that leaves all the files intact. Thereafter you can just call it from the command line.

So what I have now which seems to work is.

Code: [Select]
IF NOT @Flac@==1 GOTO end_flac_tracks
    SET dest="@TrackDir_Flac@%trackDir%"
    SET playlist="@OutRoot@\FLAC\++Playlists"
    IF NOT EXIST %dest% MKDIR %dest%
    IF NOT EXIST %playlist% MKDIR %playlist%
    PUSHD %dest%
        IF @various@==1 SET VA_tag=-T $qalbum artist=@VA@$q
        IF %embed_cover%==1 SET Cover_tag=--picture=$#x
        @tools@\acdir.exe --overwrite --output "%TrackName%.flac" --extra-opt "|image/jpeg|||@cover@" --pipe "TITLE $n/$N flac $#T & @tools@\flac.exe @Opt_Flac@ %Cover_tag% %VA_tag% %Disc_Flac_acdir% -T artist=$#a -T album=$#T -T title=$#t -T tracknumber=$n/$N -T date=$q@year@$q -T genre=$q@genre@$q -T comment=$q@comment@$q -T encoded-by=$q%USERNAME%$q -T encoding=$qFlac @Ver_Flac@ @Opt_Flac@$q - -o $#o" "@sourcecuesheet@"
        IF %add_rg%==1 @tools@\Glob.exe -v -c @tools@\metaflac.exe %RG_MetaFlac% *.flac
        REM ** Create playlist in (flac) playlist directory
        DIR /B *.flac >> temp.txt
        SET tempString=..\$cdartist$ - $album$ [$year$]\%%f
        FOR /F "tokens=* delims=" %%f IN (temp.txt) DO (ECHO %tempString%>>"..\++Playlists\$cdartist$ - $album$ [$year$].m3u")
REM        DEL temp.txt
        SET tempString=""
        IF EXIST "@cuesheet@" COPY /Y "@cuesheet@" "$cdartist$ - $album$ [$year$].cue"
        IF EXIST "@albumfile@.[*].cue" COPY /Y "@albumfile@.[*].cue" "$cdartist$ - $album$ [$year$].[*].cue"
        COPY /Y "@eaclog@" "$cdartist$ - $album$ [$year$].EAC.log"
        IF %have_cover%==1 COPY /Y "@cover@" "folder.jpg"
        REM ** Add read-only attribute to all files in the destination folder and it's subfolders.
        ATTRIB +R *.* /S
    POPD
:end_flac_tracks


Trying to add quotes to tempString still adds the quotes into the playlist file.

Edit: Ok looking at it again, I can't understand why it is working as I'm setting tempString outside the for loop, so in theory %%f should not have a value yet or am I missing something?

I think I'll stick with this for now and if I have problems with the "&", I'll look to add your batch file trick mentioned above.

Ideally I'll have to move setting the playlist directory to the ini file, but I'll wait to see what Akkurat is releasing this weekend.

Regards
Paul

Creating a playlist with REACT

Reply #11
I haven't tested this, but this is the way I tend to do things (I use labels to create what I think of as functions to keep things, IMHO, more clear):

Code: [Select]
REM ** Create playlist in (flac) playlist directory
DIR /B *.flac >> temp.txt
FOR /F "tokens=* delims=" %%f IN (temp.txt) DO CALL :WriteToPlaylist "..\$cdartist$ - $album$ [$year$]\%%f"
DEL temp.txt

Then add the "function" WriteToPlaylist to the end of the config:

Code: [Select]
:WriteToPlaylist
REM Escape ampersand and caret
SET tmpString=%1
SET tmpString=%tmpString:^=^^%
SET tmpString=%tmpString:&=^^^&%
REM Remove quotes
SET tmpString=%tmpString:"=%
REM Write filename to playlist
ECHO %tmpString%>>"..\++Playlists\$cdartist$ - $album$ [$year$].m3u"
GOTO :EOF


It may work...
I'm on a horse.

Creating a playlist with REACT

Reply #12
I haven't tested this, but this is the way I tend to do things (I use labels to create what I think of as functions to keep things, IMHO, more clear):

Code: [Select]
REM ** Create playlist in (flac) playlist directory
DIR /B *.flac >> temp.txt
FOR /F "tokens=* delims=" %%f IN (temp.txt) DO CALL :WriteToPlaylist "..\$cdartist$ - $album$ [$year$]\%%f"
DEL temp.txt

Then add the "function" WriteToPlaylist to the end of the config:

Code: [Select]
:WriteToPlaylist
REM Escape ampersand and caret
SET tmpString=%1
SET tmpString=%tmpString:^=^^%
SET tmpString=%tmpString:&=^^^&%
REM Remove quotes
SET tmpString=%tmpString:"=%
REM Write filename to playlist
ECHO %tmpString%>>"..\++Playlists\$cdartist$ - $album$ [$year$].m3u"
GOTO :EOF


It may work...


Jip, that works and is much neater. Thanks

I don't know whether it is required but I added brackets around the function call.

Should I post the entire image.cfg file here to make it easier for someone that might want to do the same or pass it on to Akkurat for inclusion in his release?

(I'm still new here and not sure what the protocol is, but I guess when I start to add the playlist variable to the ini file, then we have another fork in your and Akkurat's releases?)

Thanks again for the help, it turns something that could've been very frustrating into fun.

Regards
Paul

Creating a playlist with REACT

Reply #13
Should I post the entire image.cfg file here to make it easier for someone that might want to do the same or pass it on to Akkurat for inclusion in his release?

(I'm still new here and not sure what the protocol is, but I guess when I start to add the playlist variable to the ini file, then we have another fork in your and Akkurat's releases?)

Only if you release your own mod with that change. Now it's just your own custom REACT configuration (I too have my own very very custom setup). And there's no need to post me this, I've already planned to make creating playlists (with Tag though) as a feature in REACT in the future.

Creating a playlist with REACT

Reply #14
Only if you release your own mod with that change. Now it's just your own custom REACT configuration (I too have my own very very custom setup). And there's no need to post me this, I've already planned to make creating playlists (with Tag though) as a feature in REACT in the future.


Thanks Akkurat, I now understand how it works.

Thanks again for keeping the project moving forward and making it easier for newbies to get going.

Regards
Paul