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 15:42
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Want to rename MP3 filenames View 788 Replies 5
Original Poster Posted 2009-03-14 09:29 ·  中国 上海 浦东新区 电信
中级用户
★★
一看二跟三动手
Credits 396
Posts 188
Joined 2005-10-23 13:21
20-year member
UID 43919
From 上海
Status Offline
I have some files named
mm-66.mp3
mm-67.mp3
mm-68.mp3
I want to change them to
mm-66.mp3
mm-67.mp3
mm-68.mp3

I know this is just how it displays. But I don't know why it displays as " mm-66 3 " " mm-67 3 " " mm-68 3 "

@echo off
for /f "tokens=1,2 delims=" %%i in ('dir /b *.mp3' do echo %%i %%j
@echo\
pause


ren ?
@echo off
for /f "tokens=2 delims=" %%i in ('dir /b *.mp3' do ren ...
pause


[ Last edited by dosz on 2009-3-14 at 09:35 ]
*/. . . * .
.\* . * dosz
*/ . ./\~~~~~~~~~~~~'\. ^|◆
\* ,/,..,\,...........,\.◆
^|^| ..▎# ▎田 田 ▎ ^| ▎◆
^|^| ^&^&▎ ▎ ▎'^|'▎ o
^|^| ##■■■■■■■■■■〓
Floor 2 Posted 2009-03-14 09:38 ·  中国 广东 东莞 电信
银牌会员
★★★
批处理编程迷
Credits 1,916
Posts 752
Joined 2008-12-28 04:30
17-year member
UID 135147
Gender Male
From 广西
Status Offline
"delims=" treats single characters as delimiters, not a string.
What you want can be done with one command, no need to make it so complicated:
ren *.mp3 ?????.*
精简
=> 个人网志
Floor 3 Posted 2009-03-15 03:29 ·  中国 上海 浦东新区 电信
中级用户
★★
一看二跟三动手
Credits 396
Posts 188
Joined 2005-10-23 13:21
20-year member
UID 43919
From 上海
Status Offline
Originally posted by netbenton at 2009-3-14 09:38:
"delims=" treats single characters as delimiters, not a string.
What you want can be done with one command, no need to make it so complicated:
ren *.mp3 ?????.*


"delims="delimiter"" can be a whole character set, please look at the following example:
:: for rename mp3 filenames
@mode con cols=82 lines=33
@echo off
echo for /f "tokens=1,2 delims=" %%i in ('dir /b *.mp3') do echo %%i %%j
for /f "tokens=1,2 delims=" %%i in ('dir /b *.mp3') do echo %%i %%j
@echo\
echo for /f "delims=






[ Last edited by dosz on 2009-3-15 at 03:36 ]
Attachments
未命名.PNG
*/. . . * .
.\* . * dosz
*/ . ./\~~~~~~~~~~~~'\. ^|◆
\* ,/,..,\,...........,\.◆
^|^| ..▎# ▎田 田 ▎ ^| ▎◆
^|^| ^&^&▎ ▎ ▎'^|'▎ o
^|^| ##■■■■■■■■■■〓
Floor 4 Posted 2009-03-15 03:41 ·  中国 上海 浦东新区 电信
中级用户
★★
一看二跟三动手
Credits 396
Posts 188
Joined 2005-10-23 13:21
20-year member
UID 43919
From 上海
Status Offline
re: htnetbenton
Take a look here http://cn-dos.net/forum/viewthread.php?tid=46633
*/. . . * .
.\* . * dosz
*/ . ./\~~~~~~~~~~~~'\. ^|◆
\* ,/,..,\,...........,\.◆
^|^| ..▎# ▎田 田 ▎ ^| ▎◆
^|^| ^&^&▎ ▎ ▎'^|'▎ o
^|^| ##■■■■■■■■■■〓
Floor 5 Posted 2009-03-15 05:23 ·  中国 广东 东莞 电信
银牌会员
★★★
批处理编程迷
Credits 1,916
Posts 752
Joined 2008-12-28 04:30
17-year member
UID 135147
Gender Male
From 广西
Status Offline
It supports a character set, but not a string. Look carefully: the later "mp3" also loses the "mp",
and if the string you want to extract contains characters from that character set, it will also get split.

================================
Thanks, now I understand what's going on with that signature.
精简
=> 个人网志
Floor 6 Posted 2009-03-16 00:38 ·  中国 江西 南昌 电信
中级用户
★★
Credits 206
Posts 100
Joined 2007-07-09 20:51
19-year member
UID 93566
Gender Male
Status Offline
for /r %%i in (*.mp3) do (
for /l %%j in (1,1,100) do ren %%i mm-%%~j.mp3
)
Like this?

[ Last edited by 313885174 on 2009-3-16 at 00:39 ]
Forum Jump: