rename long file and add underscore

January 18, 2011 at 23:36:13
Specs: Windows XP
Hello,

I have a webcam, making movies and the movie is stored in this way:
20110119071051 (year, month, day, hour, minute, second and I cannot change the filename)

I would like to rename the file and split it into year, month, day, hour, minute, second with underscores, so it looks like 2011_01_19_07_10_51

How do I do this ?

Thanks in advance,
Edwin.


See More: rename long file and add underscore

Report •


#1
January 19, 2011 at 03:57:24
@echo off & setLocal EnableDELAYedeXpansion

for /f "tokens=* delims= " %%a in ('dir/b *.avi') do (
set N=%%~Na
set Y=!N:~0,4!_
set MON=!N:~4,2!_
set D=!N:~6,2!_
set H=!N:~8,2!_
set M=!N:~10,2!_
set S=!N:~12,2!
echo ren %%a !Y!!MON!!D!!H!!M!!S!%%~Xa
)


=====================================
Life is too important to be taken seriously.

M2


Report •

#2
January 19, 2011 at 10:43:57
Thanks Mechanix2Go

I'll give it a try tomorrow.


Report •

#3
January 19, 2011 at 22:59:11
Mechanix2Go

It works like a charm.
Thanks !!!


Report •
Related Solutions


Ask Question