Reputation: 1949
I have the following bat file which will look at each subfolder in my directory and create an m3u file which lists the contents of that subfolder:
@echo off
for /d %%A in (*) do @if exist "%%~A\*" (
for %%B in ("%%~A\*") do @echo %%~nxB
) > "%%~A\%%~nxA.m3u"
example: My directory called Names has subfolders Paul, Tom, Susan. Paul has files a.txt, b.txt Tom has files c.txt, d.txt Susan has files e.txt, f.txt
The bat file, in the Names directory runs. It will create:
Each of the m3u files will list that subfolder's files, one file per line.
The problem I am having is that the m3u file is ALSO listing the m3u files itself. I don't want that.
Current output:
a.txt
b.txt
Paul.m3u
Wanted output:
a.txt
b.txt
I recognize that the issue lies in my loop which isn't excluding the .m3u file extension but I'm not sure how to accomplish that. Any pointers?
Upvotes: 0
Views: 594
Reputation: 80033
for %%B in ("%%~A\*") do if "%%~nxB" neq "%%~nxA.m3u" @echo %%~nxB
[untested]
should do what you appear to want, excluding the name.ext part of the .mp3 file being created.
Note that the @
s are not required once an @echo off
has been executed.
Upvotes: 1