Computing.Net > Forums > Programming > use creation date in renaming file

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.

use creation date in renaming file

Reply to Message Icon

Name: jamaz
Date: February 17, 2007 at 11:18:34 Pacific
OS: winxp
CPU/Ram: x
Product: x
Comment:

Hey,
I'm looking for a simply way to rename certain files within a folder bt appending the mmdd of the creation date to teh file name.
Kinda like:
set dd=%date:~9,2%
set mm=%:~6,2%
ren c:\test.doc test%mm%%dd%.doc
but using creation date of that file....
Anyone able to help?
THNX


j



Sponsored Link
Ads by Google

Response Number 1
Name: dtech10
Date: February 17, 2007 at 16:50:37 Pacific
Reply:

Hi Jamaz
Try This.
I'm english with a date of dd/mm/yy so you
will have to change set dd and yy.

@echo off
setlocal EnableDelayedExpansion
for /f "tokens=1-3,* skip=4" %%a in ('dir *.* /tc /a-d ^| find /v "(s)"') do (
set CDate=%%a
set dd=!CDate:~0,2!
set mm=!CDate:~3,2!
ren %%d %%~nd!dd!!mm!%%~xd
)


0

Response Number 2
Name: Mechanix2Go
Date: February 17, 2007 at 19:15:45 Pacific
Reply:


kewl


=====================================
If at first you don't succeed, you're about average.

M2



0

Response Number 3
Name: tonysathre
Date: February 20, 2007 at 12:44:09 Pacific
Reply:

Dtech, thats awesome! I've never seen the skip option in a for loop before. What does it do? Skip the 4th token in a string?

"Computer security." — Oxymoron


0

Response Number 4
Name: dtech10
Date: February 20, 2007 at 14:18:40 Pacific
Reply:

Hi tony
No it skips the first 4 lines of the Dir command.
Thanks for the compliments from you and Mechanix.


0

Sponsored Link
Ads by Google
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 Programming Forum Home


Sponsored links

Ads by Google


Results for: use creation date in renaming file

%DATE% in batch files with win98 www.computing.net/answers/programming/date-in-batch-files-with-win98/4007.html

append creation date to filename www.computing.net/answers/programming/append-creation-date-to-filename/16017.html

Retain folders' dates in treecopy www.computing.net/answers/programming/retain-folders-dates-in-treecopy/16159.html