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-02 09:10
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » The task assigned by the supervisor is to be handed in on Monday. Hope experts can help~DOS.BAT file renaming application View 4,163 Replies 33
Original Poster Posted 2006-10-15 09:48 ·  中国 上海 嘉定区 电信
初级用户
Credits 30
Posts 14
Joined 2006-10-15 08:13
19-year member
UID 65835
Status Offline
File Renaming Application

Requirements are as follows:
1. For renaming under the command line.
2. Format: changename source
3. The extension remains unchanged.
4. destination = source + date + "@" + time, that is, the target file name is the source file name + current date + "@" + time.
For example: ack.txt, assuming the running program time is 2006-09-17, 14:22:50.
Execute change ack.
The output result is ack20060917@142250.txt

Waiting online, thank you very much...

Updated, the system is 2000.

[ Last edited by namejm on 2006-11-6 at 01:23 PM ]
Floor 2 Posted 2006-10-15 09:53 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
第一高手 第二高手

Floor 3 Posted 2006-10-15 09:55 ·  中国 上海 嘉定区 电信
初级用户
Credits 30
Posts 14
Joined 2006-10-15 08:13
19-year member
UID 65835
Status Offline
The supervisor just told me it's a DOS program, and I'm still quite green in this area. The program should run under Windows 2000. Thanks.
Floor 4 Posted 2006-10-15 10:03 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
Wait for others, I don't have a test environment in 2000
第一高手 第二高手

Floor 5 Posted 2006-10-15 10:09 ·  中国 上海 嘉定区 电信
初级用户
Credits 30
Posts 14
Joined 2006-10-15 08:13
19-year member
UID 65835
Status Offline
Fastslz, thank you. Can you help make one for XP? After all, most in the company are 2000, but there are more than a dozen that are XP~~
Floor 6 Posted 2006-10-15 10:12 ·  中国 四川 成都 移动
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
Currently, most people are using the XP system, and the 2K system is used relatively less by individual users. The date format under XP is different from that under 2K. If the user has set the short or long format of the date, even on the same XP machine, the date format will be different, and the same may be the case under 2K. Please the landlord run date and time on your 2K machine respectively and then post the results to see. Once the date problem is solved, other problems will be easy to handle.
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 7 Posted 2006-10-15 10:14 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
I never help others with their homework, heh heh. I won't reveal the secret that all the homework is copied by myself~~~

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 8 Posted 2006-10-15 10:17 ·  中国 上海 嘉定区 电信
初级用户
Credits 30
Posts 14
Joined 2006-10-15 08:13
19-year member
UID 65835
Status Offline
Thanks toiled and fastslz

C:\Documents and Settings\Administrator>date
Current date: 2006-10-14 Saturday
Enter new date: (year/month/day)

C:\Documents and Settings\Administrator>time
Current time: 22:11:17.54
Enter new time:

This is the XP at my home. The machines in the company, whether XP or 2000, also have the default time settings. Because I installed them all and didn't touch this aspect of the settings
Floor 9 Posted 2006-10-15 10:19 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
@echo off
for /F "tokens=1-3 delims=/- " %%A in ('date/T') do set DATE=%%A%%B%%C
for /F "tokens=1-2 delims=/: " %%A in ('time/T') do set TIME=%%A%%B
for %%i in (E:\ack.txt) do copy %%i E:\%%~ni%DATE%@%TIME%.txt
第一高手 第二高手

Floor 10 Posted 2006-10-15 10:21 ·  中国 上海 嘉定区 电信
初级用户
Credits 30
Posts 14
Joined 2006-10-15 08:13
19-year member
UID 65835
Status Offline
electronixtar, actually I don't want others to help with this either. I tried writing it with VB, but there were always errors. Later, the supervisor said a program under DOS was needed. I'm not very familiar with this aspect, so I found this forum to temporarily solve the immediate problem, and then I'll study it well : )
Floor 11 Posted 2006-10-15 10:27 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
TIME can only be a 4-digit number哦,If the requirement is to rename copy to move
第一高手 第二高手

Floor 12 Posted 2006-10-15 10:29 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
@echo off
setlocal EnableDelayedExpansion
set date$=%date%&&set date$=!date$:~0,10!&&set date$=!date$:-=!
set time$=%time%&&set time$=!time$:~0,8!&&set time$=!time$::=!

echo %1 %~n1%date$%@%time$%%~x1

@echo off
echo %1 %~n1%date:~0,4%%date:~5,2%%date:~8,2%@%time:~0,2%%time:~3,2%%time:~6,2%%~x1


Change "echo" to "copy"...
The running format is all: bat *.txt (needs to bring the file extension)

[ Last edited by zxcv on 2006-10-14 at 22:30 ]
Floor 13 Posted 2006-10-15 10:33 ·  中国 上海 嘉定区 电信
初级用户
Credits 30
Posts 14
Joined 2006-10-15 08:13
19-year member
UID 65835
Status Offline
fastslz: Thanks a million. I've run your test program and it works fine under XP. Now I just don't know how to run it under 2000. Could you provide your MSN so that I can contact you on Monday? Or my MSN: delonkgb@hotmail.com By the way, thanks to all the comrades who provided information above~
Floor 14 Posted 2006-10-15 10:42 ·  中国 上海 嘉定区 电信
初级用户
Credits 30
Posts 14
Joined 2006-10-15 08:13
19-year member
UID 65835
Status Offline
Once again, thank you to all the moderators and other enthusiastic friends...

By the way, moderator qwe1234567,
Can I understand that for ren *.txt *%a%.txt, I can change *.txt to test.txt to modify the TEST.TXT file? Do I need a path??

I will show you the final situation to everyone on Monday. If there are problems, trouble everyone again. Once again, thank you all for your enthusiastic help.

[ Last edited by samzj on 2006-10-15 at 10:47 ]
Floor 15 Posted 2006-10-15 10:47 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
View my profile in MSN
第一高手 第二高手

Forum Jump: