Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
64 user(s) are online (50 user(s) are browsing Forums)

Members: 0
Guests: 64

more...

Support us!

Headlines

 
  Register To Post  

Set a variable with a timestamp in cli script
Just popping in
Just popping in


See User information
Sometimes when you play old games it is better to save daily a zipfile of the content of the full directoty as it could be possible to lost some data or objects.

On Windows I created a.bat file that uses wmic to get the timestamp (so is not dependant to locale), create an file name and run 7zip to create an archive of the game folder.

As an example:

@echo off
for /"tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YY=%dt:~2,2%" set "YYYY=%dt:~0,4%" set "MM=%dt:~4,2%" set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%" set "Min=%dt:~10,2%" set "Sec=%dt:~12,2%"
set "datestamp=%YYYY%%MM%%DD%" set "timestamp=%HH%%Min%%Sec%"
set filename="E:\GOGLibrary\ShardOfSpingBackup_%datestamp%_%timestamp%.zip"
set SHARDDIR="E:\GOGLibrary\Shard of Spring"
set SEVENZIP="C:\Program Files\7-Zip\7z.exe"

echo calling ... %SEVENZIP-%filename% %SHARDDIR%
call %SEVENZIP-%filename% %SHARDDIR%

pause


I would like to create a similar script on Amiga, but I can't find how to set a variable with a timestamp.

Any suggestion? (Thank you!)


Edited by MazinKaesar on 2025/11/24 20:48:59
Go to top
Re: Set a variable with a timestamp in cli script
Not too shy to talk
Not too shy to talk


See User information
shell backtick

Go to top
Re: Set a variable with a timestamp in cli script
Just can't stay away
Just can't stay away


See User information
Yep, like @NinjaCyborg says.

For an example, I do it like this in one of my scripts:

set dt `C:Date LFORMAT "%Y%m%d%H%M%S"`

PS. You can edit the LFORMAT string to your wish, e.g. putting your underscore between the %d and the %H.

Best regards,

Niels

Go to top
Re: Set a variable with a timestamp in cli script
Just popping in
Just popping in


See User information
Thank you, will try later tonight.

Roll 3d6 six times in order.
Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )



Polls
Running AmigaOS 4 on?
AmigaOne SE/XE or microA1
Pegasos2
X5000
X1000
A1222
Sam 440/460
Classic PowerPC Amiga
WinUAE emulation
Qemu emulation
Total Votes: 199
The poll will close at 2025/12/1 12:00
5 Comments


Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project