Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
hi. first of all I'll say I'm completely ignorant at programming and stuff.. but I'm trying to do a tiny batch file to help me with my music collection. So, what I want is to create a text file with the name of each .mp3 song inside a folder. I've written this:
FOR %%A in (*.mp3) do ECHO 2>%%A.txt
ok, and it works, but I get a list of files like this:
title1.mp3.txt
title2.mp3.txt
title3.mp3.txtand what I want is to remove the mp3 part:
title1.txt
title2.txt
and so onI don't know if this is hard of easy to do, but I can't figure it out. I've tried with the rename command, and I've even found a way of removing a number of characters IN FRONT of a file name, but not at the end..
anyway, if someone can help, I'd really appreciate it
thanks in advance :)

@echo off
for /f "tokens=* delims= " %%A in ('dir *.mp3 /b') do (
echo %%A >> %%~nA.txt
)
=====================================
If at first you don't succeed, you're about average.M2

wow! that was quick. thanks a lot both of you :)
Mechanix2Go that works! I already tried with tokens and delims, but didnt find the right %%~nA variable. Now curosity has grown on me and I'll get learning a bit more about batch files. Thanks again! :D
ps. edman747 I tried yours also. What it does is create a text file with the file names in it. Probably you misunderstood my post. thanks for replying anyway :)

oops, I misunderstood what you wanted.
this will make a list of *.mp3 filenames
then change the filename extension to *.txt
example directory has two mp3's:
mysong1.mp3
mysong2.mp3
filenames.txt will contain
mysong1.txt
mysong2.txt@echo off
setlocal enabledelayedexpansion
if exist filenames.txt del filenames.txt
for %%x in (*.mp3) do echo %%x >>filenames.txt
for /f "tokens=* delims=" %%a in (filenames.txt) do (
set txtline=%%a
set txtline=!txtline:mp3=txt!
echo !txtline!>>tmp.txt)
del filename.txt & ren tmp.txt filenames.txt
endlocal

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |