home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   alt.msdos.batch      Fun with MS-DOS batch files      42,547 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 41,612 of 42,547   
   Climate Hillbilly Davis to All   
   Re: Rename One File In Batch To It's Mod   
   06 Jan 18 21:01:50   
   
   XPost: alt.comp.editors.batch, alt.msdos.batch.nt   
   From: hillbilly@appalachia.com   
      
   On Sat, 6 Jan 2018 21:15:09 +0700,  JJ says...   
      
   >   
   > On Thu, 4 Jan 2018 18:52:10 -0600, Climate Hillbilly Davis wrote:   
   > > Need to rename one file in batch to it's created date, i.e.,   
   > > "latest.gho" > "createddate.gho"   
   > >   
   > > Format example:  "01-04-2018.gho"   
   > >   
   > > Just one file, not a group.   
   > >   
   > > I use this to rename it to current date:  if exist D:\Latest.gho for /f   
   > > "tokens=1-5 delims=/ " %%d in ("%date%") do rename "D:\Latest.gho" %%e-%%   
   > > f-%%g_C.gho   
   > >   
   > > Thanks.   
   >   
   > Use this. Pass the file as the first parameter.   
   >   
   > @echo off   
   > setlocal enabledelayedexpansion   
   > if not exist %1 goto :eof   
   > for %%F in ("%~1") do (   
   >  set d=%%~tF   
   >  ren "%%F" !d:~0,2!-!d:~3,2!-!d:~6,4!%%~xF   
   > )   
      
   Perfect... thank you very much!   
      
   I can't TELL you how many people on the net have written similar batch   
   files, but took about 500 more characters to do so, and STILL didn't work   
   right.   
      
   Thanks again.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca