中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-09-24 03:13
47,812 topics / 349,917 posts / today 0 new / 48,274 members
DOS批处理 & 脚本技术(批处理室) » The task assigned by the supervisor is to be handed in on Monday. Hope experts can help~DOS.BAT file renaming application
Printable Version  4,545 / 33
Floor16 samzj Posted 2006-10-15 10:55
初级用户 Posts 14 Credits 30
Moderator qwe1234567, why did the program code you posted earlier under the 2000 environment disappear?
Floor17 不得不爱 Posted 2006-10-15 10:56
超级版主 Posts 2,044 Credits 5,310 From 四川南充

If you want to modify the TEST.TXT file, you just need to replace *.txt with test.txt. If you put this file in the folder where you need to change the file names, you can omit the path, and you can also change all TXT file names!

[ Last edited by qwe1234567 on 2006-10-15 at 10:57 ]
Floor18 samzj Posted 2006-10-15 11:00
初级用户 Posts 14 Credits 30
Thank you very much. I will see what other special functions the supervisor needs on Monday.
Floor19 zh159 Posted 2006-10-15 11:00
金牌会员 Posts 1,467 Credits 3,687
Refer to the modification by moderator qwe1234567 for 2K:

XP

2K

The operation method is: bat *.txt (with extension)
Floor20 fastslz Posted 2006-10-15 12:18
铂金会员 Posts 2,315 Credits 5,493 From 上海
Integrated with zxcv, qwe1234567 moderators, DOS.BAT content
Floor21 3742668 Posted 2006-10-15 13:00
荣誉版主 Posts 718 Credits 2,013
```
On Error Resume Next

Set objArgs = WScript.Arguments
If objArgs.Count < 1 Then
WScript.Echo "Drag files to this file with mouse or run with arguments!"
WScript.Quit
End If

For Each strFile In objArgs
strNewFile = Mid(strFile,1,InStrRev(strFile,".") _
- 1) & Replace(Date,"-","") & "@" _
& Replace(Time,":","") & _
Mid(strFile,InStrRev(strFile,".") )
If Len(Trim(strNewFile)) = 0 Then
strNewFile = strFile & Replace(Date,"-","") & _
"@" & Replace(Time,":","")
End If
ReName strFile , strNewFile
Next


Sub ReName (strFile,strNewFile)
WScript.Echo strFile & vbLf & strNewFile
CreateObject("Scripting.FileSystemObject") _
.MoveFile strFile,strNewFile
End Sub
```
Copy to SendTo, then select all the files to be modified and send to... That's it.
Or call with multiple parameters in bat, you can change the first line of the ReName procedure from vblf to "," to display the change details for forming a log.
Floor22 milertom Posted 2006-10-15 22:51
初级用户 Posts 11 Credits 28
I only have less than 11:00 AM here, why are you all at 2006-10-15 13:00, Moderator, is there a problem with the server time?
Floor23 samzj Posted 2006-10-16 22:53
初级用户 Posts 14 Credits 30
Dear all experts,

Just now, my supervisor told me that it was tested in the 2000 server en environment. I copied the date and time.

C:\Documents and Settings\Administrator>date
The current date is: 10/16/2006 Mon
Enter the new date: (mm-dd-yy)

C:\Documents and Settings\Administrator>time
The current time is: 10:44:17.73
Enter the new time:

fastslz, can you log in to MSN? I want to ask you some questions, thank you very much
Floor24 不得不爱 Posted 2006-10-16 23:04
超级版主 Posts 2,044 Credits 5,310 From 四川南充
```
set a=%date:~6,4%%date:~0,2%%date:~3,2%@%time:~0,2%%time:~3,2%%time:~6,2%%time:~9,2%
ren *.txt *%a%.txt
```
Floor25 maya0su Posted 2006-10-16 23:13
中级用户 Posts 131 Credits 241
@echo off
set /p yy=Path of the file to be processed:
set /p uu=Name of the file to be processed:
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 (%yy%:\%uu%) do copy %%i %yy%:\%%~ni%DATE%@%TIME%.txt

Borrowed fastslz's code, but with the above几句 added, it can process files on any drive letter! Also: When displaying this sentence, do not enter a colon after the drive letter!
Floor26 fastslz Posted 2006-10-17 00:01
铂金会员 Posts 2,315 Credits 5,493 From 上海
Originally posted by samzj at 2006-10-16 22:53:
Hello everyone
Just now, my supervisor told me that the test was carried out in the 2000 server en environment. I copied the date and time.
C:\Documents and Settings\Administrator>date
The current date is: 10/16/2006 Mon
Enter t ...


The time sequence in the English version is different.
If I replace
for /F "tokens=1-3 delims=/- " %%A in ('date/T') do set DATE=%%A%%B%%C

in my code with
for /F "tokens=1-3 delims=/- " %%A in ('date/T') do set DATE=%%C%%B%%A

that is, just change the order, which is easy to grasp.
Floor27 vkill Posted 2006-10-17 01:09
金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽
The best for such a problem

echo %time%
echo %date%

Post these two displays
Floor28 不得不爱 Posted 2006-10-17 02:21
超级版主 Posts 2,044 Credits 5,310 From 四川南充
```batch
@echo off
set /p lj=Path of the file to be processed:
set /p wjm=Name of the file to be processed:
copy %lj%%wjm% %lj%%wjm%%date:~10,4%%date:~4,2%%date:~7,2%@%time:~0,2%%time:~3,2%%time:~6,2%.txt
```
Floor29 samzj Posted 2006-10-17 03:58
初级用户 Posts 14 Credits 30
Thanks to everyone's enthusiastic help~~~~
Today, under the remote guidance of moderator qwe1234567, this problem was finally temporarily solved.
Test environment: 2000 server en

C:\Documents and Settings\Administrator>date
The current date is: 10/16/2006 Mon
Enter the new date: (mm-dd-yy)

C:\Documents and Settings\Administrator>time
The current time is: 15:56:45.35
Enter the new time:


set a=%date:~10,4%%date:~4,2%%date:~7,2%@%time:~0,2%%time:~3,2%%time:~6,2%
copy c:\test.bat test%a%.bat

Finally successful, thank you all who posted to help!!!!
Floor30 samzj Posted 2006-10-17 03:59
初级用户 Posts 14 Credits 30
And also need to thank fastslz for the patient explanation~~~~~~ and so on and so forth
Prev  1 2 3  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023