China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-11 10:49
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [fixed] Batch rename song titles View 1,268 Replies 11
Original Poster Posted 2009-02-25 19:06 ·  中国 四川 绵阳 电信
初级用户
Credits 75
Posts 46
Joined 2007-09-25 22:21
18-year member
UID 98274
Gender Male
Status Offline
After using dir d:\music\*.*>列表1.txt /b

the format of 列表1.txt is as follows

JJ Lin-At the Moment of Decisive Battle
Fish Leong-Premonition of Happiness
Teresa Teng-Love in the Heart
Teresa Teng-With Me There Is You
Teresa Teng-Taipei Girl
JJ Lin-ENCORE
…………
Suppose it is changed to the following format:

列表2.txt

JJ Lin - At the Moment of Decisive Battle
Fish Leong - Premonition of Happiness (LIVE Complete Record edition)
Teresa Teng - Love in the Heart
Teresa Teng - With Me There Is You
Teresa Teng - Taipei Girl
JJ Lin - ENCORE
Teresa Teng - Always Smile

That is, change "-" into " - "
Of course it's easy to replace it directly in the list, then use the corrected list (列表2.txt) to modify the corresponding song names in song list 1 in the music library! Changing them one by one is too troublesome, so I'd like to ask how to do this in batch!

[ Last edited by jycel on 2009-2-27 at 07:53 ]
努力学习!我行的!
Floor 2 Posted 2009-02-25 20:18 ·  中国 江西 赣州 电信
银牌会员
★★★★
Credits 2,025
Posts 1,122
Joined 2007-09-05 20:15
18-year member
UID 96653
Gender Male
Status Offline
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
netbenton +2 2009-02-25 22:33
Floor 3 Posted 2009-02-25 20:38 ·  中国 广东 韶关 电信
高级用户
★★★
CMD感染者
Credits 691
Posts 383
Joined 2008-05-23 00:38
18-year member
UID 119451
Gender Male
Status Offline
Originally posted by jycel at 2009-2-25 07:06 PM:
Changing them one by one is too troublesome ...

Doesn't Notepad have a replace function?
Floor 4 Posted 2009-02-25 21:26 ·  中国 四川 绵阳 电信
初级用户
Credits 75
Posts 46
Joined 2007-09-25 22:21
18-year member
UID 98274
Gender Male
Status Offline
Originally posted by radem at 2009-2-25 08:38 PM:

Doesn't Notepad have a replace function?

Notepad does have a replace function. What I mean is batch-changing the music names in the music library:
Singer1-Song1 changed to Singer1 - Song1
Singer2-Song2 changed to Singer2 - Song2
Singer3-Song3 changed to Singer3 - Song3
And everyone can try it too: if there are a large number of characters in Notepad, replace still isn't as fast as a batch file!
努力学习!我行的!
Floor 5 Posted 2009-02-25 21:32 ·  中国 四川 绵阳 电信
初级用户
Credits 75
Posts 46
Joined 2007-09-25 22:21
18-year member
UID 98274
Gender Male
Status Offline
Originally posted by tireless at 2009-2-25 08:18 PM:
@echo off
for /f "tokens=1,* delims=-" %%中 in ('dir /b d:\music') do (
ren "%%中-%%丮" "%%中 - %%丮"
)


[ Last edited by tireless on 2009-2- ...

A question:
Does "%%中 mean all the original filenames in the music library
what about -%%丮?
Do you mean first get the dir listing, then split each line into two characters, and then rename them?
努力学习!我行的!
Floor 6 Posted 2009-02-25 21:34 ·  中国 江西 赣州 电信
银牌会员
★★★★
Credits 2,025
Posts 1,122
Joined 2007-09-05 20:15
18-year member
UID 96653
Gender Male
Status Offline
Just run the code in reply #2 directly.
--------------------------------
JJ Lin-At the Moment of Decisive Battle ← split into the red and blue parts.
Floor 7 Posted 2009-02-25 21:38 ·  中国 四川 绵阳 电信
初级用户
Credits 75
Posts 46
Joined 2007-09-25 22:21
18-year member
UID 98274
Gender Male
Status Offline
Originally posted by tireless at 2009-2-25 09:34 PM:
Just run the code in reply #2 directly.
--------------------------------
JJ Lin-At the Moment of Decisive Battle ← split into the red and blue parts.

No response at all!
努力学习!我行的!
Floor 8 Posted 2009-02-25 21:43 ·  中国 江西 赣州 电信
银牌会员
★★★★
Credits 2,025
Posts 1,122
Joined 2007-09-05 20:15
18-year member
UID 96653
Gender Male
Status Offline
I overlooked one point. Change it to this:
@echo off
for /f "tokens=1,* delims=-" %%中 in ('dir /b d:\music') do (
ren "d:\music\%%中-%%丮" "%%中 - %%丮"
)


[ Last edited by tireless on 2009-2-25 at 21:45 ]
Floor 9 Posted 2009-02-25 21:45 ·  中国 四川 绵阳 电信
初级用户
Credits 75
Posts 46
Joined 2007-09-25 22:21
18-year member
UID 98274
Gender Male
Status Offline
It worked. Thank you so much!
I still don't understand this “%%中-%%丮”, hehe! Please explain it a bit
努力学习!我行的!
Floor 10 Posted 2009-02-25 21:54 ·  中国 江西 赣州 电信
银牌会员
★★★★
Credits 2,025
Posts 1,122
Joined 2007-09-05 20:15
18-year member
UID 96653
Gender Male
Status Offline
“%%中-%%丮” is the same as “%%a-%%b” ... just using Chinese instead. The a b or 中 丮 in it are arranged according to ASCII encoding, and the ASCII codes of those two Chinese characters are also right next to each other. (Converted with the software ASCII码随心换)

[ Last edited by tireless on 2009-2-25 at 21:55 ]
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
alex9527 +1 2009-02-26 10:20
Floor 11 Posted 2009-02-25 22:35 ·  中国 广东 东莞 电信
银牌会员
★★★
批处理编程迷
Credits 1,916
Posts 752
Joined 2008-12-28 04:30
17-year member
UID 135147
Gender Male
From 广西
Status Offline
Learned something. I originally thought for tokens could only use letters and numbers.
Brilliant!
精简
=> 个人网志
Floor 12 Posted 2009-02-25 22:50 ·  中国 广东 江门 电信
中级用户
★★
Credits 338
Posts 175
Joined 2007-10-21 15:30
18-year member
UID 100351
Gender Male
Status Offline
Brother tireess likes playing with unusual stuff too...
Forum Jump: