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
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
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.
Summary: I'm looking for help with the DATE function in batch files and saw your postings on http://www.computing.net/programming/wwwboard/forum/2249.html %DATE% worked well on my winXP box for naming backup f...
Summary: Dear all does someone explain me why the code ::- echo off setLocal EnableDelayedExpansion for /f "tokens=* delims= " %%a in ('dir /b/a-d *.txt') do ( copy %%a %%~Na_%date:~-4,4%%date:~-7,2%%date:~-1...
Summary: OK, DOS geezers, am about to upgrade/migrate a RAID V array. Would like to retain (or recreate) original folder/directory creation dates in copying thousands of nested folders. Any hope in xxcopy or r...