Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. @echo off
  2. REM Christmas Accounting
  3. REM
  4. setlocal EnableDelayedExpansion
  5. if "%*" == "" (
  6. set day=today
  7. for /f "tokens=2,3 delims=/ " %%a in ('echo %date%') do (
  8. set mm=%%a
  9. set dd=%%b
  10. )
  11. set dd=1!dd!
  12. set /a dd-=100
  13. set mm=1!mm!
  14. set /a mm-=100
  15. if !mm!==12 (
  16. if !dd! GEQ 25 set /a day=!dd!-24
  17. )
  18. if !mm!==1 (
  19. if !dd! LEQ 5 set /a day=!dd!+7
  20. )
  21. if !day! == today echo It is not a day of Christmas today ^(!mm!/!dd!^).
  22. )
  23. if NOT "%*" == "" (
  24. set day=%1
  25. )
  26. if exist %0 (
  27. set filename=%0
  28. ) else (
  29. set filename=%0.bat
  30. )
  31. if !day! GEQ 1 (
  32. if !day! LEQ 12 (
  33. if !day! == 1 set suffix=st
  34. if !day! == 2 set suffix=nd
  35. if !day! == 3 set suffix=rd
  36. if !day! GEQ 4 set suffix=th
  37. set array=-1
  38. for /f "tokens=1* delims= " %%a in ('type !filename!') do (
  39. if "%%a" == "DATA" (
  40. set /a array=!array!+1
  41. set gift.!array!=%%b
  42. )
  43. )
  44. echo Because it's the !day!!suffix! day of Christmas,
  45. echo by now my true love should have sent to me:
  46. set multi=1
  47. for /l %%a in (!day!,-1,1) do (
  48. set /a num=%%a*!multi!
  49. if !num! LEQ 9 set num= !num!
  50. if %%a == 1 (
  51. if !day! == 1 (
  52. echo !num! !gift.0!
  53. ) else echo and !num! !gift.%%a!
  54. )
  55. if %%a GTR 1 echo !num! !gift.%%a!
  56. set /a multi+=1
  57. )
  58. ) else echo Usage: %0 [1-12]
  59. ) else echo Usage: %0 [1-12]
  60.  
  61. exit /b
  62.  
  63. DATA partridge in a pear tree.
  64. DATA partridges in pear trees.
  65. DATA turtle doves
  66. DATA French hens,
  67. DATA calling birds,
  68. DATA golden rings^!
  69. DATA geese a-laying,
  70. DATA swans a-swimming,
  71. DATA maids a-milking,
  72. DATA ladies dancing,
  73. DATA lords a-leaping,
  74. DATA pipers piping,
  75. DATA drummers drumming,
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement