ZTree.com  | ZEN  | About...  

 Index   Back

[ZEP] batch param %d: leading zeros!?   [ZEP]

By: GoSlow2GoFast     RI  
Date: Jan 23,2023 at 21:59
In Response to: [ZEP] batch param %d: leading zeros!? (andreas)

> hi dear community!
>
> had to create a batch file with %d in the line mask.
>
> want to rename some files with random names to color="#003399">"yyyy-mm-dd_hh-mm-ss.*"
> so set line mask to "ren
> %4.%5#%d.*" (# beeing a place holder to be changed to tab
> with my editor)
>
> results in lines like:
> ren
> 73ea3b3e3f4499887b8b2d619c8be87f7005.jpg# 3-01-2023
> 8:31:59.*
> day + hour have no leading zero. bothers me ... (I'am aware of
> the CO-1K setting; blank instead of zero is OK for me on display)
>
> would like to have leading zeros for Day+Hour when using %d batch
> param.
>
> curiosity:
> there is an additional blank after # (eaten away by the forum sw even
> if text tagged as code!?).
> where does is come from? it appears as well if I take any other char
> instead of #
> ???
>
> thanks for your valuable help! andreas

As a bit of a work workaround you could add the leading zero yourself when needed with a little BAT logic. This seems to work in a test here...

for /f "tokens=1,2" %%%%A in ("%d") do (
set dt=%%%%A
set tm=%%%%B
)
if "%%dt:~1,1%%" == "-" set dt=0%%dt%%
if "%%tm:~1,1%%" == ":" set tm=0%%tm%%

rem Timestamp = %%dt%% %%tm%%

55 views      
 

Messages in this Thread

 
96,194 Postings in 12,153 Threads, 350 registered users, 26 users online (1 registered, 25 guests)
Index | Admin contact |   Forum Time: Jan 27, 2023 - 1:09 am UTC  |  Hits:53,203,704  (937 Today )
RSS Feed