1iJaCk icon

datetime.bat

1iJaCk | PRO | 03/18/17 06:36:59 PM UTC | 0 ⭐ | 196 👁️ | Never ⏰ | []
Batch |

6.07 KB

|

None

|

0 👍

/

0 👎

::
:: JK'D Blame-Game Agreement 1.0a, "Finger-Pointer Edition", written by JaCk
::
::: No Warrenty, No Guarentee, No Support, AS-IS
:::
::: USE AT YOUR OWN RISK 
::: By sheer discretion and without notification, JaCk, retains the all rights, including exemptions, revokation of exemptions of this agreement!
:::
::: By Running this script or ANY portion of it's, this script's, contents, you agree to the following:
::: - that you fully understand what these commands, expressions, functions, and/or script(s) or portions of script(s) do
::: - that you take responsibility for any actions, damages, physical losses, intelecual property losses, and/or losses of ANY kind
::: - that you DO NOT seek compensation of any kind, monies or otherwise, in ANY FORM, from previous, current and future parties; not limited to:
:::    -- anyone
:::    -- everyone
:::    -- it's author(s) 
:::    -- it's contributor(s)
:::    -- any beneficataries
:::    -- users
:::    -- distributors
::
:::::::::::::::::::::::::::::::::::::::
 
:::::::::::::::::::::::::::::::::::::::
::
:: by JXE\JaCk :: 03-09-2017  :: datetime.cmd - show me clock plox, plox, ploxplox
::
:: -- Concepts sourced from a recollection (JaCk's brain dump) of 
:: ---- methods found stackexchange site(s) by various users customized with JaCk's taste
::             ::   ::
:::::::::::::::::::::::::::::::::::::::
@echo off & @setlocal EnableDelayedExpansion
 
 
 
 
:::::::::::::::::::::::::::::::::::::::
::                                   ::
::    one line that give your all    ::
::    date, and time broken down     ::
::                                   ::
:::::::::::::::::::::::::::::::::::::::
 
:: Single Line
    set "_dt_example_single_month=!date:~4,2!" & set "_dt_example_single_day=!date:~7,2!" & set "_dt_example_single_year=!date:~-4,4!" & set "_dt_example_single_hour=!time:~0,2!" & set "_dt_example_single_minute=!time:~3,2!" & set "_dt_example_single_second=!time:~-5,2!" & set "_dt_example_single_milisecond=!time:~-2,2!"
 
:: Broken Down
    set "_dt_example_broken-down_milisecond=!time:~-2,2!"
    set "_dt_example_broken-down_second=!time:~-5,2!"
    set "_dt_example_broken-down_minute=!time:~3,2!"
    set "_dt_example_broken-down_hour=!time:~0,2!"
    set "_dt_example_broken-down_year=!date:~-4,4!"
    set "_dt_example_broken-down_day=!date:~7,2!"
    set "_dt_example_broken-down_month=!date:~4,2!"
 
:: print all the vars
    set _dt_example_broken
    set _dt_example_single
        
:::::::::::::::::::::::::::::::::::::::
::                                   ::
::             ::   ::               ::
::                                   ::
:::::::::::::::::::::::::::::::::::::::
 
 
 
:::::::::::::::::::::::::::::::::::::::
::                                   ::
::   two lines that give your all    ::
::    date, and time broken down     ::
::                                   ::
:::::::::::::::::::::::::::::::::::::::
 
:: two line to concat date time with only numerals
    set "_dd_=/!date:* =!" & set "_tt_=!time:~0,-3!" 
    set "_dt_=!_dd_:/=!!_tt_::=!"   
    
:: print all the vars   
    set _dd_
    set _tt_
    set _dt_
 
:::::::::::::::::::::::::::::::::::::::
::                                   ::
::             ::   ::               ::
::                                   ::
:::::::::::::::::::::::::::::::::::::::
 
 
 
:::::::::::::::::::::::::::::::::::::::
::                                   ::
::    one line that give your all    ::
::    date, and time broken down     ::
::                                   ::
:::::::::::::::::::::::::::::::::::::::
 
:: one line that give your all date, and time broken down
    for /f "tokens=2-8 delims=:/. " %%a in ('echo !date! !time!') do ( set "_dt_example_for_single_dtconcat=%%a%%b%%c%%d%%e%%f%%g" & set "_dt_example_for_single_month=%%a" & set "_dt_example_for_single_day=%%b" & set "_dt_example_for_single_year=%%c" & set "_dt_example_for_single_hour=%%d" & set "_dt_example_for_single_minute=%%e" & set "_dt_example_for_single_second=%%f" & set "_dt_example_for_single_milisecond=%%g" )
    
 
:: one liner broken down for readability that give your all date, and time broken down
    for /f "tokens=2-8 delims=:/. " %%a in ('
        echo !date! !time!
    ') do (
        set "_dt_example_for_broken-down_dtconcat=%%a%%b%%c%%d%%e%%f%%g" 
        set "_dt_example_for_broken-down_month=%%a"
        set "_dt_example_for_broken-down_day=%%b"
        set "_dt_example_for_broken-down_year=%%c"
        set "_dt_example_for_broken-down_hour=%%d"
        set "_dt_example_for_broken-down_minute=%%e"
        set "_dt_example_for_broken-down_second=%%f"
        set "_dt_example_for_broken-down_milisecond=%%g" 
    )
 
    (
        echo Returns: 
        echo/ set "_dt_example_for_broken-down_dtconcat=0309201716580219"
        echo/ set "_dt_example_for_broken-down_month=03"
        echo/ set "_dt_example_for_broken-down_day=09"
        echo/ set "_dt_example_for_broken-down_year=2017"
        echo/ set "_dt_example_for_broken-down_hour=16"
        echo/ set "_dt_example_for_broken-down_minute=58"
        echo/ set "_dt_example_for_broken-down_second=02"
        echo/ set "_dt_example_for_broken-down_milisecond=19"
        echo/
    )
    
:: print all the vars
    set _dt_example_for_single_
    set _dt_example_for_broken
    
:::::::::::::::::::::::::::::::::::::::
::                                   ::
::             ::   ::               ::
::                                   ::
:::::::::::::::::::::::::::::::::::::::
 
 
 
 
:::::::::::::::::::::::::::::::::::::::
::                                   ::
::    One line to dump all files     ::
::        older than one day         ::
::                                   ::
:::::::::::::::::::::::::::::::::::::::
 
:: Find files that are older than 1 day
:: -p = Path
:: -m = mask (search criteria, can be *.*)
:: -d +0 = (0 day old) OR (0 day new)
:: -c "cmd /c echo @file" = execute quoted command for everyone returned @file variable. @file expands to the full file path
    echo forfiles -p !temp!\ -m *.* /d +0 /c "cmd /c echo @file"
 
:::::::::::::::::::::::::::::::::::::::
::                                   ::
::             ::   ::               ::
::                                   ::
:::::::::::::::::::::::::::::::::::::::

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎