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,607 of 42,547   
   JJ to Climate Hillbilly Davis   
   Re: Rename One File In Batch To It's Mod   
   06 Jan 18 21:15:09   
   
   XPost: alt.comp.editors.batch, alt.msdos.batch.nt   
   From: jj4public@vfemail.net   
      
   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   
   )   
      
   --- 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