• Renaming files to a date

    From Bill Gordon@1:3634/22 to All on Thu Sep 3 08:26:11 2015
    At one time, I was able to write a batch file that would rename any file to
    the present date.

    For example, it was possible to rename info.txt to 090315.txt. I have long since forgotten how to do this.

    Could someone refresh my memory? I'm using Windows XP SP3 on the particular machine that I need to do this on.

    Thanks
    --- SBBSecho 2.27-Win32
    * Origin: * Origin: *Square One BBS-sq1bbs.com (1:3634/22)
  • From Ben Ritchey@1:393/68 to Bill Gordon on Thu Sep 3 13:34:58 2015
    * An ongoing debate between Bill Gordon and All rages on ...

    At one time, I was able to write a batch file that would rename any
    file to the present date.

    I use FDate to set Env vars to date values, then construct a batch file to use the vars as needed. Should work for you ... file FDATE16A.ZIP in BFDS area on my BBS. or, http://cmech.dynip.com/filebase.bbs/bfds/fdate16a.zip (see docs) :)

    --
    Guardien Fide :^)

    Ben aka cMech Web: http://cmech.dynip.com
    Email: fido4cmech(at)lusfiber.net
    Home page: http://cmech.dynip.com/homepage/
    WildCat! Board 24/7 +1-337-984-4794 any BAUD 8,N,1

    --- GoldED+/W32-MSVC
    * Origin: FIDONet - The Positronium Repository (1:393/68)
  • From Bill Gordon@1:3634/22 to Ben Ritchey on Thu Sep 3 17:08:01 2015
    Thanks, I'll look it over
    --- SBBSecho 2.27-Win32
    * Origin: * Origin: *Square One BBS-sq1bbs.com (1:3634/22)
  • From Ben Ritchey@1:393/68 to Bill Gordon on Thu Sep 3 17:23:28 2015
    * An ongoing debate between Bill Gordon and Ben Ritchey rages on ...

    I do this daily on bootup:

    File: SEToday.Bat

    === Cut ===
    @Echo OFF
    Set YMD=
    Set JJJ=
    Set YY=
    Set MM=
    Set TODAY=
    Set YTDY=
    Set YY-1=
    Set MM-1=
    Set DD-1=
    Fdate.exe /Ff /Atoday /O"yymmdd" /P"@SET YMD=" >$stdy$.bat
    Fdate.exe /Ff /Atoday /O"jjj" /P"@SET JJJ=" >>$stdy$.bat
    Fdate.exe /Ff /Atoday /O"yy" /P"@SET YY=" >>$stdy$.bat
    Fdate.exe /Ff /Atoday /O"mm" /P"@SET MM=" >>$stdy$.bat
    Fdate.exe /Ff /Atoday /O"dd" /P"@SET DD=" >>$stdy$.bat
    Fdate.exe /Ff /Atoday /O"d1" /P"@SET TODAY=" >>$stdy$.bat
    Fdate.exe /Fadd /Atoday /N-1 /O"yymmdd" /P"@SET YTDY=" >>$stdy$.bat
    Fdate.exe /Fadd /Atoday /N-365 /O"yy" /P"@SET YY-1=" >>$stdy$.bat
    Fdate.exe /FM /Atoday /N-1 /O"mm" /P"@SET MM-1=" >>$stdy$.bat
    Fdate.exe /Fadd /Atoday /N-1 /O"dd" /P"@SET DD-1=" >>$stdy$.bat
    Call $stdy$.bat
    Del $stdy$.bat

    If %IM%.==. Set IM=C:\BJR\IM
    If %GOLDED%.==. Set GOLDED=C:\GED
    If %PCWRITE%.==. Set PCWRITE=C:\BJR\PCWRITE
    If %DJGPP%.==. Set DJGPP=C:\DJGPP\DJGPP.ENV

    === Cut ===

    Thanks, I'll look it over
    --- SBBSecho 2.27-Win32
    * Origin: * Origin: *Square One BBS-sq1bbs.com (1:3634/22)

    --
    Guardien Fide :^)

    Ben aka cMech Web: http://cmech.dynip.com
    Email: fido4cmech(at)lusfiber.net
    Home page: http://cmech.dynip.com/homepage/
    WildCat! Board 24/7 +1-337-984-4794 any BAUD 8,N,1

    --- GoldED+/W32-MSVC
    * Origin: FIDONet - The Positronium Repository (1:393/68)
  • From mark lewis@1:3634/12.73 to Bill Gordon on Thu Sep 3 16:20:48 2015
    03 Sep 15 08:26, you wrote to All:

    At one time, I was able to write a batch file that would rename any file
    to
    the present date.

    For example, it was possible to rename info.txt to 090315.txt. I have long since forgotten how to do this.

    Could someone refresh my memory? I'm using Windows XP SP3 on the
    particular
    machine that I need to do this on.

    do you have powershell on that box? i don't know if it is needed for this or not, though...

    anyway, here's a neat winwhatever script that can do the date and time thing...
    currently it outputs YYYYMMDDhhmmss format... this is all native winwhatever and uses no external 3rd party schtuffings...

    just run it to see the output... the main key is the bottom ":mygettime" section which must be as written the first line after the label is pretty long and the second line starts with the "rem" statement... the output, as the file currently is, should be something like

    [quote]
    -------------------
    20150903173045
    20150903173045 set blerg=x:\foo\bar
    20150903173046 terminating
    [/quote]

    so in your script that needs to rename files, you would include the entire ":mygettime" section and then in your script whereever you need the current datetime stamp, you would

    call :mygettime
    ren somefile.txt %ldt%.txt

    any time you need or want the datetime stamp, you "call :mygettime: first and then use "%ldt%" for the stamp where ever you want it...

    ==== Begin "LDT.BAT" ====
    @echo off
    Echo -------------------
    call :mygettime
    Echo %ldt%
    set blerg=x:\foo\bar
    call :mygettime
    echo %ldt% set blerg=%blerg%


    :end
    call :mygettime
    echo %ldt% %0 terminating
    echo.
    if not '%blerg%' == '' set blerg=
    goto :EOF

    :mygettime
    for /F "usebackq tokens=1,2 delims==" %%i in (`wmic os get LocalDateTime /VALUE
    NUL`) do if '.%%i.'=='.LocalDateTime.' set ldt=%%j
    rem set ldt=%ldt:~0,4%-%ldt:~4,2%-%ldt:~6,2% %ldt:~8,2%:%ldt:~10,2%:%ldt:~12,2% set ldt=%ldt:~0,4%%ldt:~4,2%%ldt:~6,2%%ldt:~8,2%%ldt:~10,2%%ldt:~12,2%
    exit /b
    ==== End "LDT.BAT" ====

    )\/(ark

    ... Cats have the simplest of taste - the best will suffice
    ---
    * Origin: (1:3634/12.73)