1iJaCk

datetime.bat

Mar 18th, 2017
237
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 6.07 KB | None | 0 0
  1. ::
  2. :: JK'D Blame-Game Agreement 1.0a, "Finger-Pointer Edition", written by JaCk
  3. ::
  4. ::: No Warrenty, No Guarentee, No Support, AS-IS
  5. :::
  6. ::: USE AT YOUR OWN RISK
  7. ::: By sheer discretion and without notification, JaCk, retains the all rights, including exemptions, revokation of exemptions of this agreement!
  8. :::
  9. ::: By Running this script or ANY portion of it's, this script's, contents, you agree to the following:
  10. ::: - that you fully understand what these commands, expressions, functions, and/or script(s) or portions of script(s) do
  11. ::: - that you take responsibility for any actions, damages, physical losses, intelecual property losses, and/or losses of ANY kind
  12. ::: - that you DO NOT seek compensation of any kind, monies or otherwise, in ANY FORM, from previous, current and future parties; not limited to:
  13. :::    -- anyone
  14. :::    -- everyone
  15. :::    -- it's author(s)
  16. :::    -- it's contributor(s)
  17. :::    -- any beneficataries
  18. :::    -- users
  19. :::    -- distributors
  20. ::
  21. :::::::::::::::::::::::::::::::::::::::
  22.  
  23. :::::::::::::::::::::::::::::::::::::::
  24. ::
  25. :: by JXE\JaCk :: 03-09-2017  :: datetime.cmd - show me clock plox, plox, ploxplox
  26. ::
  27. :: -- Concepts sourced from a recollection (JaCk's brain dump) of
  28. :: ---- methods found stackexchange site(s) by various users customized with JaCk's taste
  29. ::             ::   ::
  30. :::::::::::::::::::::::::::::::::::::::
  31. @echo off & @setlocal EnableDelayedExpansion
  32.  
  33.  
  34.  
  35.  
  36. :::::::::::::::::::::::::::::::::::::::
  37. ::                                   ::
  38. ::    one line that give your all    ::
  39. ::    date, and time broken down     ::
  40. ::                                   ::
  41. :::::::::::::::::::::::::::::::::::::::
  42.  
  43. :: Single Line
  44.     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!"
  45.  
  46. :: Broken Down
  47.     set "_dt_example_broken-down_milisecond=!time:~-2,2!"
  48.     set "_dt_example_broken-down_second=!time:~-5,2!"
  49.     set "_dt_example_broken-down_minute=!time:~3,2!"
  50.     set "_dt_example_broken-down_hour=!time:~0,2!"
  51.     set "_dt_example_broken-down_year=!date:~-4,4!"
  52.     set "_dt_example_broken-down_day=!date:~7,2!"
  53.     set "_dt_example_broken-down_month=!date:~4,2!"
  54.  
  55. :: print all the vars
  56.     set _dt_example_broken
  57.     set _dt_example_single
  58.        
  59. :::::::::::::::::::::::::::::::::::::::
  60. ::                                   ::
  61. ::             ::   ::               ::
  62. ::                                   ::
  63. :::::::::::::::::::::::::::::::::::::::
  64.  
  65.  
  66.  
  67. :::::::::::::::::::::::::::::::::::::::
  68. ::                                   ::
  69. ::   two lines that give your all    ::
  70. ::    date, and time broken down     ::
  71. ::                                   ::
  72. :::::::::::::::::::::::::::::::::::::::
  73.  
  74. :: two line to concat date time with only numerals
  75.     set "_dd_=/!date:* =!" & set "_tt_=!time:~0,-3!"
  76.     set "_dt_=!_dd_:/=!!_tt_::=!"  
  77.    
  78. :: print all the vars  
  79.     set _dd_
  80.     set _tt_
  81.     set _dt_
  82.  
  83. :::::::::::::::::::::::::::::::::::::::
  84. ::                                   ::
  85. ::             ::   ::               ::
  86. ::                                   ::
  87. :::::::::::::::::::::::::::::::::::::::
  88.  
  89.  
  90.  
  91. :::::::::::::::::::::::::::::::::::::::
  92. ::                                   ::
  93. ::    one line that give your all    ::
  94. ::    date, and time broken down     ::
  95. ::                                   ::
  96. :::::::::::::::::::::::::::::::::::::::
  97.  
  98. :: one line that give your all date, and time broken down
  99.     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" )
  100.    
  101.  
  102. :: one liner broken down for readability that give your all date, and time broken down
  103.     for /f "tokens=2-8 delims=:/. " %%a in ('
  104.         echo !date! !time!
  105.     ') do (
  106.         set "_dt_example_for_broken-down_dtconcat=%%a%%b%%c%%d%%e%%f%%g"
  107.         set "_dt_example_for_broken-down_month=%%a"
  108.         set "_dt_example_for_broken-down_day=%%b"
  109.         set "_dt_example_for_broken-down_year=%%c"
  110.         set "_dt_example_for_broken-down_hour=%%d"
  111.         set "_dt_example_for_broken-down_minute=%%e"
  112.         set "_dt_example_for_broken-down_second=%%f"
  113.         set "_dt_example_for_broken-down_milisecond=%%g"
  114.     )
  115.  
  116.     (
  117.         echo Returns:
  118.         echo/ set "_dt_example_for_broken-down_dtconcat=0309201716580219"
  119.         echo/ set "_dt_example_for_broken-down_month=03"
  120.         echo/ set "_dt_example_for_broken-down_day=09"
  121.         echo/ set "_dt_example_for_broken-down_year=2017"
  122.         echo/ set "_dt_example_for_broken-down_hour=16"
  123.         echo/ set "_dt_example_for_broken-down_minute=58"
  124.         echo/ set "_dt_example_for_broken-down_second=02"
  125.         echo/ set "_dt_example_for_broken-down_milisecond=19"
  126.         echo/
  127.     )
  128.    
  129. :: print all the vars
  130.     set _dt_example_for_single_
  131.     set _dt_example_for_broken
  132.    
  133. :::::::::::::::::::::::::::::::::::::::
  134. ::                                   ::
  135. ::             ::   ::               ::
  136. ::                                   ::
  137. :::::::::::::::::::::::::::::::::::::::
  138.  
  139.  
  140.  
  141.  
  142. :::::::::::::::::::::::::::::::::::::::
  143. ::                                   ::
  144. ::    One line to dump all files     ::
  145. ::        older than one day         ::
  146. ::                                   ::
  147. :::::::::::::::::::::::::::::::::::::::
  148.  
  149. :: Find files that are older than 1 day
  150. :: -p = Path
  151. :: -m = mask (search criteria, can be *.*)
  152. :: -d +0 = (0 day old) OR (0 day new)
  153. :: -c "cmd /c echo @file" = execute quoted command for everyone returned @file variable. @file expands to the full file path
  154.     echo forfiles -p !temp!\ -m *.* /d +0 /c "cmd /c echo @file"
  155.  
  156. :::::::::::::::::::::::::::::::::::::::
  157. ::                                   ::
  158. ::             ::   ::               ::
  159. ::                                   ::
  160. :::::::::::::::::::::::::::::::::::::::
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment