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-06-25 07:06
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Interface-free version Batch file renaming beat1.3 [20061214] update View 12,425 Replies 63
Floor 16 Posted 2006-12-14 05:01 ·  中国 安徽 合肥 电信
新手上路
Credits 14
Posts 6
Joined 2006-11-03 22:59
19-year member
UID 69456
Gender Male
Status Offline
A very useful tool. Just don't know why...
Drag and drop a folder and then execute, it will freeze
Floor 17 Posted 2006-12-14 05:10 ·  中国 河南 郑州 电信
中级用户
★★
Credits 439
Posts 170
Joined 2006-01-09 20:29
20-year member
UID 48707
Status Offline
Originally posted by linjie at 2006-12-14 05:01:
Dragging and dropping a folder and then executing will cause a freeze



Sorry
Variables were not enclosed in ""
Poor support for spaces
Sorry
The top post has been updated
bat c c++
Floor 18 Posted 2006-12-14 05:16 ·  中国 安徽 合肥 电信
新手上路
Credits 14
Posts 6
Joined 2006-11-03 22:59
19-year member
UID 69456
Gender Male
Status Offline
Now it's normal. The thread starter is very powerful...
Floor 19 Posted 2006-12-14 08:01 ·  中国 江西 赣州 电信
高级用户
★★
论坛上抢劫的
Credits 551
Posts 246
Joined 2006-09-21 12:35
19-year member
UID 63270
Status Offline
Can't help but say, the first simple renaming code is too complicated!! Give my batch COPY and rename!!
1  @echo off
2 set /p msg=Please enter the path to be renamed:
3 set msg=%msg:"=%
4 set /p word=Please enter the file extension to be copied:
5 set word=%word:"=%
6 set /p msg2=Please enter the new folder location and folder name (can not exist):
7 set msg2=%msg2:"=%
8 set /p word2=Please enter the new file extension:
9 set word2=%word2:"=%
10 if not exist %msg2%\ md %msg2%\
11 setlocal enabledelayedexpansion
12 dir /b/on "%msg%\"*."%word%" >%msg2%\txt.lst
13 for /f %%i in (%msg2%\txt.lst) do (
14 set /a num+=1
15 set name=00!num!
16 copy %msg%\"%%i" %msg2%\!name:~-3!%.!word2!
17 )
18 )
19 del %msg2%\txt.lst

Disadvantage, need to generate temporary files!
If only used for renaming, you can delete the three lines 6, 7, 10 and change msg2 to msg, copy to ren
Hehe, showing off my proficiency!!

[ Last edited by lotus516 on 2006-12-14 at 08:08 AM ]
Floor 20 Posted 2006-12-15 01:54 ·  中国 河南 郑州 电信
中级用户
★★
Credits 439
Posts 170
Joined 2006-01-09 20:29
20-year member
UID 48707
Status Offline
Originally posted by lotus516 at 2006-12-14 08:01:
Can't help but want to say, the first simple renaming code is too complicated!! Give my batch COPY and rename!!
1  @echo off
2 set /p msg=Please enter the path to be renamed:
3 set msg=%msg:"= ...

Not bad, oh
bat c c++
Floor 21 Posted 2006-12-29 11:28 ·  中国 浙江 宁波 鄞州区 电信
新手上路
Credits 3
Posts 2
Joined 2006-12-29 10:28
19-year member
UID 74920
Gender Male
Status Offline
Thanks! ! It's really great! !
Floor 22 Posted 2006-12-29 13:20 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
Originally posted by a9319751 at 2006-12-4 03:36 PM:
C:\Documents and Settings\Administrator>pren
GNU Pren beat1.3
Usage: pren

Startup:
/h, --help print this help.
/s, --short TV p ...


Met an acquaintance, heh heh, I fixed my problem as you said, posting it here, see if you see it over there first

@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
SET YEAR=%DATE:~0,4%&SET MONTH=%DATE:~5,2%&SET DAY=%DATE:~8,2%
CALL :ALG MONTH %MONTH%&&CALL :ALG DAY %DAY%

:TOP
CLS
SET /P BIRTHDAY=When's your birthday?(Month And Day):
ECHO %BIRTHDAY%|FINDSTR /R "^**">nul||GOTO TOP
FOR /F "tokens=1,2 delims=.:;-/" %%i IN ("%BIRTHDAY%") DO CALL :ALG BM %%i&CALL :ALG BD %%j
IF NOT %BM% GTR 0 (GOTO TOP) ELSE IF %BM% GTR 12 GOTO TOP
IF NOT %BD% GTR 0 (GOTO TOP) ELSE IF %BD% GTR 31 GOTO TOP
FOR /L %%i IN (1,1,12) DO (
if %%i geq 8 (set d1=30&&set d2=31) else set d1=31&&set d2=30
set /a st=%%i%%2
if !st! equ 0 (set M%%i=!d2!) else set M%%i=!d1!)
SET /A LM=(%YEAR%-2000)%%4
IF NOT %LM% EQU 0 (SET M2=28) ELSE SET M2=29
IF %BM% GTR %MONTH% SET GO=GTR
IF %BM% EQU %MONTH% SET GO=EQU
IF %BM% LSS %MONTH% SET /A NEWYEAR=%YEAR%+1&&SET GO=LSS
GOTO %GO%

:GTR
SET /A MsgM=%BM%-%MONTH%-1
SET /A MsgD=!M%MONTH%!-%DAY%+%BD%
FOR /L %%i IN (%MONTH%,1,%BM%) DO SET /A DALL=!DALL!+M%%i
SET /A DALL=%DALL%+%MsgD%-M%MONTH%-M%BM%
GOTO MSG

:EQU
SET /A MsgM=0
IF %BD% GTR %DAY% SET /A MsgD=%BD%-%DAY%&&GOTO MSG
IF %BD% EQU %DAY% SET MsgD=0&&GOTO MSG
IF %BD% LSS %DAY% SET /A NERA=%DAY%-%BD%&&GOTO LSS

:LSS
SET /A OsgM=12-%MONTH%
SET /A OsgD=!M%MONTH%!-%DAY%
FOR /L %%i IN (%MONTH%,1,12) DO SET /A OALL=!OALL!+M%%i
SET /A OALL=%OALL%+%OsgD%-M%MONTH%
SET /A LM=(%NEWYEAR%-2000)%%4
IF NOT %LM% EQU 0 (SET M2=28) ELSE SET M2=29
SET /A NsgM=%BM%
SET /A NsgD=%BD%
FOR /L %%i IN (1,1,%BM%) DO SET /A NALL=!NALL!+M%%i
SET /A NALL=%NALL%+%BD%-M%BM%
SET /A MsgM=%OsgM%+%NsgM%-1
SET /A MsgD=%OsgD%+%NsgD%
SET /A DALL=%OALL%+%NALL%
GOTO MSG

:MSG
SET GT=0
IF %MsgD% GTR 31 SET /A MsgM=%MsgM%+1&&SET /A MsgD=%MsgD%-31
IF NOT "%NERA%" == "" (SET MSG1= 你在%NERA%天前刚过完生日!) ELSE SET MSG1=.
IF NOT "%MsgM%" == "0" (SET MSG2= 未来的生日在预计的%MsgM%个月) ELSE SET MSG2= 未来的生日在预计的
IF NOT "%MsgD%" == "0" (SET MSG3=%MsgD%天后!) ELSE SET MSG2= &&SET MSG3=祝你生日快乐&&SET GT=5
IF NOT "%DALL%" == "" (SET MSG4= 距你生日共还有%DALL%天!) ELSE SET MSG4=.

:CON
IF NOT "%GT%" == "0" mode con cols=41 lines=7&&CLS&&SET /A GT=%GT%-1&&ECHO Happy birthday to you
ECHO ========================================
ECHO%MSG1%
ECHO%MSG2%%MSG3%
ECHO%MSG4%
ECHO ========================================
IF NOT "%GT%" == "0" (
COLOR FC
ping 127.1 -n 1>nul 2>nul
COLOR CF
ping 127.1 -n 1>nul 2>nul
GOTO CON
)

:END
PAUSE>nul
GOTO :EOF

:ALG
SET CHKALG=%2
ECHO %CHKALG%|findstr /b "0">nul&&SET %1=%CHKALG:~1%||SET %1=%CHKALG%
GOTO :EOF



[ Last edited by everest79 on 2007-1-1 at 10:28 AM ]
Recent Ratings for This Post ( 2 in total) Click for details
RaterScoreTime
lxmxn +4 2006-12-29 13:50
a9319751 +4 2007-01-01 05:23
Floor 23 Posted 2006-12-29 13:51 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

  Not bad. Add points..

     P.S. Eyes are also dazzled. =_=!!
Floor 24 Posted 2006-12-29 13:56 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
Happy birthday!
The original encountered a problem is that set /a day=08 will be wrong, which was discovered by the poster
Floor 25 Posted 2006-12-29 14:02 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

  The set /a will recognize the number after the equal sign. If the first character after the equal sign is 0, it will consider it as an octal number. If the first two characters after the equal sign are 0x, it will consider it as a hexadecimal number.
Floor 26 Posted 2007-01-01 04:12 ·  中国 广东 肇庆 电信
初级用户
★★
Credits 152
Posts 74
Joined 2005-12-01 23:06
20-year member
UID 46314
Status Offline
How come you guys are so awesome!
Floor 27 Posted 2007-01-01 23:27 ·  中国 广东 广州 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
Originally posted by lxmxn at 2006-12-29 01:02 AM:

set /a will recognize the number after the equal sign. If the first character after the equal sign is 0, it will be considered an octal number. If the first two characters after the equal sign are 0x, it will be considered a hexadecimal...

I found the reason that makes your eyes dazzled. When I pasted it up, I missed a variable
Floor 28 Posted 2007-01-04 11:38 ·  中国 广西 南宁 中移铁通
新手上路
Credits 2
Posts 1
Joined 2007-01-04 10:54
19-year member
UID 75424
Gender Male
Status Offline
Thank you for the suggestion. The new version already supports path settings. Added the function to change the extension. Ignored the folder. Can the function of changing the extension be made to change the specified extension to the desired one? For example, change *.txt to *.exe
Floor 29 Posted 2007-02-01 04:12 ·  中国 浙江 温州 乐清市 电信
新手上路
Credits 7
Posts 4
Joined 2007-01-22 09:37
19-year member
UID 77327
Gender Male
Status Offline
There are really many experts here.
Floor 30 Posted 2007-02-10 18:55 ·  中国 山西 移动
初级用户
Credits 27
Posts 14
Joined 2007-02-10 16:57
19-year member
UID 79176
Gender Male
Status Offline
Take it, plus support, plus an admiration~~
Forum Jump: