Computing.Net > Forums > Programming > batch create txt files

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

batch create txt files

Reply to Message Icon

Name: sand_e
Date: January 21, 2007 at 18:33:10 Pacific
OS: windows xp
CPU/Ram: 1gb
Comment:

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.txt

and what I want is to remove the mp3 part:

title1.txt
title2.txt
and so on

I 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 :)



Sponsored Link
Ads by Google

Response Number 1
Name: edman747
Date: January 21, 2007 at 19:02:17 Pacific
Reply:

try this
@echo off
if exist mp3s.txt del mp3s.txt
for %%x in (*.mp3) do echo %%x >>mp3s.txt


0

Response Number 2
Name: Mechanix2Go
Date: January 21, 2007 at 19:44:38 Pacific
Reply:

@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



0

Response Number 3
Name: sand_e
Date: January 21, 2007 at 20:07:38 Pacific
Reply:

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 :)


0

Response Number 4
Name: edman747
Date: January 21, 2007 at 20:15:05 Pacific
Reply:

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



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: batch create txt files

With Batch create .txt file www.computing.net/answers/programming/with-batch-create-txt-file/9975.html

VB Create Txt file, single line iss www.computing.net/answers/programming/vb-create-txt-file-single-line-iss/16759.html

batch editing txt file www.computing.net/answers/programming/batch-editing-txt-file/16671.html