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,611 of 42,547   
   Climate Hillbilly Davis to All   
   Re: Rename One File In Batch To It's Mod   
   06 Jan 18 22:45:14   
   
   XPost: alt.comp.editors.batch, alt.msdos.batch.nt   
   From: hillbilly@appalachia.com   
      
   On Sat, 6 Jan 2018 21:31:03 -0700,  Grant Taylor says...   
      
   >   
   > 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:   
      
   It's not a deal at all. The batch file is small to begin with.   
      
   I've got @echo off, spaces and cls's and moves and program starts, and   
   it's only 494 bytes.   
      
   > @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)   
      
   That worked fine too. Thanks.   
      
   > 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.  }:-)   
      
   No space in the extension, so all is well.   
      
   I'm not sending a parameter, so I just changed the %1 to the name of the   
   file that I produce later in the batch file.   
      
   One question, though... what is the %~1? I also put the name of the file   
   there and it still works. What is the difference in %1 and %~1?   
      
   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