I want to create a script in those that renames a file by putting the date of the day in the name itself. Something like this: myarq_2004_05_30.zip. That is myarq_aaaa_mm_dd.zip (year, month and day). Can you do this in Windows?
How to set a variable with the date in Windows?
- dr_gori
- Moderador
- Posts: 5026
- Joined: Mon, 03 May 2004 3:08 pm
- Location: Portland, OR USA
- Contact:
Thomas F. G
Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered
Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered
Yes, it's perfectly possible! There are several ways to do this. I will put two of them:
Windows NT, 2000, XP \r\n
You create a script called setTodayD .txt with this text within:
hence you run this script:
] Windows 98, 95 or \r\n
Windows NT, 2000, XP \r\n
You create a script called setTodayD .txt with this text within:
set data=
hence you run this script:
DATE /T >setdata.txt
COPY settodayd.txt+setdata.txt data_var.bat
CALL data_var.bat
SET data=%data: =%
SET data=%data:/=%
:: __________________________________________________________________
::
:: Batch File: DATETIME.BAT
:: Author: Frank-Peter Schultze
::
:: Updates: http://www.fpschultze.de/b6.htm
:: Enhancement Req.
:: And Bug Reports: support@fpschultze.de
::
:: Built/Tested On: MS-DOS 6.22, Windows 98 SE, Windows NT 4.0
:: Requirements: OS: MS-DOS 5+, Windows NT4+
::
:: Purpose: Set DATE/TIME Variable To The System Date/Time.
::
:: Syntax: No arguments required.
::
:: State Changes: Reduces free environment space.
::
:: Assumptions And
:: Limitations: * Does not handle low environment errors.
::
:: Last Update: 2002-02-25
:: __________________________________________________________________
::
@Echo Off
If Not %1'==/?' Goto Begin
Echo Sets DATE and TIME variable to the system date and time.
Echo.
Echo [Call] DATETIME
Goto End
:Begin
For %%V In (DATE TIME) Do Set %%V=
If %OS%'==Windows_NT' Goto %OS%
Echo @Prompt %%%%1 %%%%0 :: $D $T$_Set DATE=%%%%3$_Set TIME=%%%%4$_>%TEMP%.\$ATETIM0.BAT
%COMSPEC% /C %TEMP%.\$ATETIM0.BAT > %TEMP%.\$ATETIM1.BAT
Call %TEMP%.\$ATETIM1.BAT
Del %TEMP%.\$ATETIM?.BAT
Goto End
:Windows_NT
For /F "Tokens=2" %%D In ('Date /T') Do (Set DATE=%%D)
For /F %%T In ('Time /T') Do (Set TIME=%%T)
:End
-
- Information
-
Who is online
Users browsing this forum: No registered users and 1 guest