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,610 of 42,547    |
|    Grant Taylor to Climate Hillbilly Davis    |
|    Re: Rename One File In Batch To It's Mod    |
|    06 Jan 18 21:31:03    |
   
   XPost: alt.comp.editors.batch, alt.msdos.batch.nt   
   From: gtaylor@tnetconsulting.net   
      
   On 01/06/2018 08:01 PM, Climate Hillbilly Davis wrote:   
   > 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.   
      
   If you're trying to save as many bytes as possible, try this:   
      
   @setlocal enabledelayedexpansion   
   @if exist %1 for %%F in ("%~1") do @(   
   @set d=%%~tF   
   @ren "%%F" !d:~0,2!-!d:~3,2!-!d:~6,4!%%~xF)   
      
   You save multiple characters by not using @ECHO OFF and instead putting   
   the @ character in front of commands that would otherwise show up on the   
   screen. - There's simply fewer commands than the bytes in the "@ECHO   
   OFF" string.   
      
   I also question the lack of (double) quotes around %1 in the if   
   statement. I guess it's fairly safe to not have them in the new name of   
   the ren(ame) command. Unless the extension has a space in it. }:-)   
      
      
      
   --   
   Grant. . . .   
   unix || die   
      
   --- 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