Computing.Net > Forums > Disk Operating System > Rename file with date

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Rename file with date

Reply to Message Icon

Name: Gernot
Date: October 23, 2003 at 08:10:52 Pacific
OS: DOS - Win2k
CPU/Ram: pent 4 - 256 mb
Comment:

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




Sponsored Link
Ads by Google

Response Number 1
Name: dtech10
Date: October 23, 2003 at 15:34:13 Pacific
Reply:

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_%%c

Rem add this line
set t=%t:~0,8%

set DATE_TIME=%d%_%t%
echo %DATE_TIME%
ren test.jpg %t%.jpg


0
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Rename file with date

Create file with date and time www.computing.net/answers/dos/create-file-with-date-and-time/13843.html

Rename file with current date www.computing.net/answers/dos/rename-file-with-current-date/13069.html

Rename file with date and increment www.computing.net/answers/dos/rename-file-with-date-and-increment/15614.html