Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi All
i use the following code in a bat file to scan with irfanview. The file test.jpg is generated and should be renamed with the current time. It works fine with date but when using time there will be a space between seconds and .jpg and an error will occur.ren test.jpg 17_04_35 .jpg
The syntax of the command is incorrect.I have no idea how to get rid of the space or how to shorten the variable t
c:
cd "c:\program files\irfanview\"
i_view32.exe/scanhidden/ /convert=c:\program files\irfanview\test.jpg
for /F "tokens=1,2,3,4 delims=/ " %%i in ('date/t') do set d=%%k_%%i_%%j
FOR /F "tokens=1,2,3 delims=:.," %%a in ("%TIME%") do set t=%%a_%%b_%%c
set DATE_TIME=%d%_%t%
echo %DATE_TIME%
ren test.jpg %t%.jpg

Hi Germot
for /F "tokens=1,2,3,4 delims=/ " %%i in ('date/t') do set d=%%k_%%i_%%j
FOR /F "tokens=1,2,3 delims=:.," %%a in ("%TIME%") do set t=%%a_%%b_%%cRem add this line
set t=%t:~0,8%set DATE_TIME=%d%_%t%
echo %DATE_TIME%
ren test.jpg %t%.jpg

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |