Does Total Commander have a date variable?
Moderators: Hacker, petermad, Stefan2, white
-
- Junior Member
- Posts: 12
- Joined: 2014-03-05, 09:15 UTC
Does Total Commander have a date variable?
Hi
Does Total Commander have a date variable?
I need a date variable in YYYYMMDDHHMMSS format for timestamp for 7z archives.
Does Total Commander have a date variable?
I need a date variable in YYYYMMDDHHMMSS format for timestamp for 7z archives.
Re: Does Total Commander have a date variable?
No.
PiotrMP006 wrote: 2023-02-08, 08:59 UTC
I need a date variable in YYYYMMDDHHMMSS format for timestamp for 7z archives.
Where? How? What do you do? Explain your use-case.
Re: Does Total Commander have a date variable?
PiotrMP006 wrote: 2023-02-08, 08:59 UTC I need a date variable in YYYYMMDDHHMMSS format for timestamp for 7z archives.
Code: Select all
@echo off
REM runtime variables parsing
Setlocal EnableDelayedExpansion
REM date/time variables:
:: date !d! is yyyymmdd
for /f "tokens=1-3 delims=:,./- " %%g in ("%date%") do set d=%%i%%h%%g
:: time !t! is hhmmssms
:: for /f "tokens=1-4 delims=:,./-" %%g in ("%time%") do set t=%%g & set t=!t: =0! & set t=!t:~,2!%%h%%i%%j
:: time !t! is hhmmss
for /f "tokens=1-4 delims=:,./-" %%g in ("%time%") do set t=%%g & set t=!t: =0! & set t=!t:~,2!%%h%%i
REM archiving
7z.exe a TargetArchive_!d!!t!.zip .\SourceFolder\* -tzip -aoa -mmt -ssw -stl -ssp -y -mx9
#278521 User License
Total Commander [always the latest version, including betas] x86/x64 on Win10 x64/Android 10/15
Total Commander [always the latest version, including betas] x86/x64 on Win10 x64/Android 10/15
Re: Does Total Commander have a date variable?
Here a modified version and a example button.
Creates a 7z archive of the current source dir in the target dir.
The archive is named according to the source dir with the date and time added.
A sample button
Here the cmd for it
Creates a 7z archive of the current source dir in the target dir.
The archive is named according to the source dir with the date and time added.
A sample button
Code: Select all
TOTALCMD#BAR#DATA
C:\TEMP\Test\f1\test.cmd
%T\%B %P
C:\WINDOWS\System32\imageres.dll,-68
test
-1
Code: Select all
@echo off
REM runtime variables parsing
Setlocal EnableDelayedExpansion
REM date/time variables:
:: date !d! is yyyymmdd
for /f "tokens=1-3 delims=:,./- " %%g in ("%date%") do set d=%%i%%h%%g
:: time !t! is hhmmssms
:: for /f "tokens=1-4 delims=:,./-" %%g in ("%time%") do set t=%%g & set t=!t: =0! & set t=!t:~,2!%%h%%i%%j
:: time !t! is hhmmss
for /f "tokens=1-4 delims=:,./-" %%g in ("%time%") do set t=%%g & set t=!t: =0! & set t=!t:~,2!%%h%%i
REM archiving
"C:\Program Files\7-Zip\7z.exe" a %1_!d!!t!.7z %2* -aoa -mmt -ssw -stl -ssp -y -mx9
Windows 11 Home, Version 24H2 (OS Build 26100.4061)
TC 11.55 RC2 x64 / x86
Everything 1.5.0.1391a (x64), Everything Toolbar 1.5.2.0, Listary Pro 6.3.2.88
QAP 11.6.4.4 x64
TC 11.55 RC2 x64 / x86
Everything 1.5.0.1391a (x64), Everything Toolbar 1.5.2.0, Listary Pro 6.3.2.88
QAP 11.6.4.4 x64
Re: Does Total Commander have a date variable?
Poll Date/time as new Parameters for Button bar, user cmd - viewtopic.php?t=75669
F4MiniMenu (Forum) - Open selected file(s) from TC in defined editor(s) - A (minimalistic) clone of F4Menu
Source at GitHub (AutoHotkey). TCSyncComments (copy file comments)
Source at GitHub (AutoHotkey). TCSyncComments (copy file comments)
Re: Does Total Commander have a date variable?
%date% and %time% are localized and depend on settings.
For example Americans use 12-31-2022; I use 31-12-2022.
A more universal approach:
Resulting in:
For example Americans use 12-31-2022; I use 31-12-2022.
A more universal approach:
Code: Select all
@echo off & setlocal
for /f "tokens=2 usebackq delims=.=" %%x in (`wmic os get LocalDateTime /format:list ^|findstr "="`) Do set "NOW=%%x"
echo Current local time : %NOW%
Resulting in:
Code: Select all
Current local time : 20230208211109
Re: Does Total Commander have a date variable?
@NotNull
Thank you.
Looks quite a pretty one to me.
Alas, as they say: "The WMI command-line (WMIC) utility is deprecated as of Windows 10, version 21H1, and as of the 21H1 semi-annual channel release of Windows Server. This utility is superseded by Windows PowerShell for WMI (see Chapter 7—Working with WMI). This deprecation applies only to the WMI command-line (WMIC) utility..."
Still works, though (and hope will for sometime yet).
NB different output:
Code: Select all
@echo off
REM runtime variables parsing
Setlocal EnableDelayedExpansion
wmic os get LocalDateTime /format:list
echo Current local time
echo:
for /f "tokens=2 delims=.=" %%x in ('wmic os get LocalDateTime /format:list ^|findstr "="') do set "now=%%x"
echo tc ghisler board: yyyymmddhhmmss
echo "date/time": %now%
:: 20230210100947
echo:
for /f "tokens=2 delims==+" %%x in ('wmic os get LocalDateTime /format:list ^|findstr "="') do set "c=%%x" & set d=!c:.=! & set d=!d:~,17!
echo custom: yyyymmddhhmmssms
echo date/time full: !c!
:: 20230210100947.876000
echo date/time trim: !c:~,-3!
:: 20230210100947.876
echo date/time no dot: !d!
:: 20230210100947876
echo date only: !d:~,8!
:: 20230210
echo time without ms: !d:~8,6!
:: 100947
echo time with ms no dot: !d:~8!
:: 100947876
echo time with ms and dot: !c:~8,10!
:: 100947.876
echo:
:: wait 7 seconds then exit
@echo wait a bit
ping -n 8 ::1 >nul
exit/b
:: https://ghisler.ch/board/viewtopic.php?t=78412
:: https://ghisler.ch/board/viewtopic.php?p=426930
:: https://learn.microsoft.com/en-us/windows/win32/wmisdk/wmic
:: https://ss64.com/nt/wmic.html
:: https://ss64.com/nt/syntax-substring.html
#278521 User License
Total Commander [always the latest version, including betas] x86/x64 on Win10 x64/Android 10/15
Total Commander [always the latest version, including betas] x86/x64 on Win10 x64/Android 10/15
Re: Does Total Commander have a date variable?
for a quick solution with winrar:
Code: Select all
TOTALCMD#BAR#DATA
%comspec% /c
rar.exe a -os -vt -m3 -tl -ep1 -ag" [YYYY-MM-DDTHHMMSS]" "%T%O.rar" %P%N
TOTALCMD64.EXE,8
rar.exe [YYYY-MM-DDTHHMMSS] %T%O.rar
Re: Does Total Commander have a date variable?
Shorter and more human-readable powershell based option for getting date and time in windows cmd:
example.cmd
Date/time format options (a file name/path-friendly representation of the current date and time in 24-hour format; case-sensitive):
And getting back to the OP's request, making 7z archives with YYYYMMDDHHMMSS timestamp format:
example.cmd
Code: Select all
@echo off
REM runtime variables parsing
Setlocal EnableDelayedExpansion
echo getting date/time (in specific output format)
echo:
for /f "delims=" %%# in ('powershell get-date -format "{yyyy-MM-dd HH:mm}"') do set d=%%#
echo yyyy-MM-dd HH:mm
echo !d!
echo:
for /f "delims=" %%# in ('powershell get-date -format "{yyyy-MM-dd HH:mm:ss}"') do set d=%%#
echo yyyy-MM-dd HH:mm:ss
echo !d!
echo:
for /f "delims=" %%# in ('powershell get-date -format "{yyyyMMdd_HHmm}"') do set d=%%#
echo yyyyMMdd_HHmm
echo !d!
echo:
for /f "delims=" %%# in ('powershell get-date -format "{yyyy-MM-dd HH:mm:ss.fff}"') do set d=%%#
echo yyyy-MM-dd HH:mm:ss.fff (with milliseconds)
echo !d!
echo:
for /f "delims=" %%# in ('powershell get-date -format "{yyyy-MM-dd HH:mm:ss.ffff}"') do set d=%%#
echo yyyy-MM-dd HH:mm:ss.ffff (with 4-digit millisecond)
echo !d!
echo:
Code: Select all
yyyyMMddTHHmmssffff
yyyy 4-digit year
MM 2-digit month
dd 2-digit day
T letter T as a [common] time separator [if needed]
HH 2-digit hour
mm 2-digit minute
ss 2-digit second
ffff 4-digit millisecond (f, ff, fff for 1/10, 1/100, and millisecond)
Code: Select all
@echo off
REM runtime variables parsing
Setlocal EnableDelayedExpansion
REM date/time variables:
for /f "delims=" %%d in ('powershell get-date -format "{yyyyMMddHHmmss}"') do set d=%%d
REM archiving:
7z.exe a TargetArchive_!d!.zip .\SourceFolder\* -tzip -aoa -mmt -ssw -stl -ssp -y -mx9
#278521 User License
Total Commander [always the latest version, including betas] x86/x64 on Win10 x64/Android 10/15
Total Commander [always the latest version, including betas] x86/x64 on Win10 x64/Android 10/15
Re: Does Total Commander have a date variable?
This doesn't require a variable. The archive will be created with the current date anyway. And if the date needs to be set according to the last modified file, then the -stl key is used.
I don't know why you decided that the question is about the name of the archive, but speed is much more important than readability, and powershell slows down a lot at the first start. I would use nircmd and 7zG to see the normal progress of packaging in the GUI rather than the console window:
Code: Select all
TOTALCMD#BAR#DATA
%COMMANDER_PATH%\Progs\NirCmd\nircmd.exe exec min "%COMMANDER_PATH%\Progs\7-Zip\7zG.exe" a "~$currdate.yyyyMMdd$~$currtime.HHmmss$.7z" -mx -m0=LZMA2:fb273 -m1=LZMA2:lc4 -scsUTF-16LE -y
@"%WL"
wcmicons.dll,30
Pack selected to <yyyyMMddHHmmss>.7z
Overquoting is evil! 👎