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-04 06:56
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to change a double extension into a single one?? For example, change *.avi.rmvb to *.flv View 930 Replies 7
Original Poster Posted 2007-04-21 03:08 ·  中国 山东 济南 联通
初级用户
Credits 20
Posts 9
Joined 2007-04-21 00:17
19-year member
UID 85898
Gender Male
Status Offline
How to change a double extension into a single one?? For example, change *.avi.rmvb to *.flv
Floor 2 Posted 2007-04-21 03:13 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
You posted this twice
Floor 3 Posted 2007-04-21 03:21 ·  中国 广东 广州 电信
银牌会员
★★★
Credits 1,206
Posts 517
Joined 2007-03-25 01:18
19-year member
UID 82819
Gender Male
Status Offline
@echo off & setlocal enabledelayedexpansion
for /f "tokens=* " %%i in ('dir /b ^| findstr /i "avi.rmvb"') do (
set filename=%%i
set filename=!filename: =_-!
for /f "tokens=1,2,3 delims=. " %%i in ("!filename!") do set filename=%

%i.flv
set filename=!filename:_-= !
ren "%%i" "!filename!"
)
pause

Heh, I'm still not an expert, and the code I wrote is too long... don't mind it.
知,不觉多。不知,乃求知
Floor 4 Posted 2007-04-22 01:39 ·  中国 江西 赣州 电信
高级用户
★★
论坛上抢劫的
Credits 551
Posts 246
Joined 2006-09-21 12:35
19-year member
UID 63270
Status Offline
Floor 5 Posted 2007-04-22 01:47 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
Everything the poster above said is wrong. In another thread, the OP was asking how to convert *.rmvb video format to *.flv format.
Floor 6 Posted 2007-04-22 01:49 ·  中国 北京 中国中信股份有限公司
荣誉版主
★★★
Credits 2,013
Posts 718
Joined 2006-02-18 07:07
20-year member
UID 50550
Status Offline

@echo off
for %%i in (*.avi.rmvb) do call :Print "%%~ni"
pause
goto :Eof

:Print
echo %~n1.flv
goto :Eof

I haven't written batch files for a long time, so it feels much less familiar now.
If the printed result is correct after running it, you can try passing %%i to :Print as %2, and then change echo to ren
Floor 7 Posted 2007-04-22 01:53 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
The poster above, look at reply #5

And then look at this thread
http://www.cn-dos.net/forum/viewthread.php?tid=29891
Floor 8 Posted 2007-04-22 02:01 ·  中国 北京 中国中信股份有限公司
荣誉版主
★★★
Credits 2,013
Posts 718
Joined 2006-02-18 07:07
20-year member
UID 50550
Status Offline
Why be so fixated on it?
It's mainly just discussing the approach.
Besides, it's nothing more than replacing ren/echo with commands like mencoder.exe -ffourcc FLV1 -of lavf -lavfopts ……
Forum Jump: