Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

- Batch... - Downloading a list of words, because we can't type out the months manually... - Not using switch case hackswitch case hack - VERY SLOW - converting the text file to lowercase and saving it in another file - run it a second time without deleting the text files created and it will be even slower - Something ticks the script off while converting the dic.txt file to lowercase, this sets echo back on - This spoiler thing has messed up formatting by the way...

- Batch... - Downloading a list of words, because we can't type out the months manually... - Not using switch case hack - VERY SLOW - converting the text file to lowercase and saving it in another file - run it a second time without deleting the text files created and it will be even slower - Something ticks the script off while converting the dic.txt file to lowercase, this sets echo back on - This spoiler thing has messed up formatting by the way...

- Batch... - Downloading a list of words, because we can't type out the months manually... - Not using switch case hack - VERY SLOW - converting the text file to lowercase and saving it in another file - run it a second time without deleting the text files created and it will be even slower - Something ticks the script off while converting the dic.txt file to lowercase, this sets echo back on - This spoiler thing has messed up formatting by the way...

added some stuff
Source Link

Now, this method has many pros over other methods, some being:

  • You can have any abbreviation of the word! E.g. Jan or Janu for January!
  • "You never know when some Pope or President is going to make us switch to another calendar, and then tons of date parsing/formatting code will instantly become worthless!" This is never a problem with our method!
  • The user is sent confirmation prompts, better safe than sorry!

The Code:

Now, this method has many pros over other methods, some being:

  • You can have any abbreviation of the word! E.g. Jan or Janu for January!
  • "You never know when some Pope or President is going to make us switch to another calendar, and then tons of date parsing/formatting code will instantly become worthless!" This is never a problem with our method!
  • The user is sent confirmation prompts, better safe than sorry!

The Code:

Source Link

Batch

What you're asking for is non-trivial. However I have found the perfect solution for you! How this works is by downloading a highly intricate list of the English language to your hard-disk. The input is then checked against the downloaded list and the final name of the month is given! Genius!

@ECHO OFF
setlocal EnableDelayedExpansion
REM Remove this at the end ^^^
REM First off, we have to get the user's input
set /p abbreviatedUserInput= Please input your abbreviated form of the month: 
REM echo out confirmation message. Without this, the thing won't work
SET /P variableThatIsUsedForConfirmation= Are you sure you want to look for %abbreviatedUserInput% (Y/N)? 
REM if the user said no, send him elsewhere
if /i {%variableThatIsUsedForConfirmation%}=={n} (goto :hell)
REM to keep things clean, we clear the screen!
cls
ECHO Prepare for launch!
REM make sure the user reads what we wrote, we spent time on this and the user must understand that... 
REM BTW this pings an incorrect ip address and waits 3000 millisex for the output
ping 1.1.1.1 -n 1 -w 3000 > nul
REM to keep things clean, we clear the screen!
cls
REM We must inform the user that something is going on, otherwise they might get bored and quit the app
ECHO LOA-DING!
REM Now, how this works is by utilizing the dictionary.. I believe we all know what that is. First of all, let's get a dictionary!
powershell -Command "(New-Object Net.WebClient).DownloadFile('http://www.mieliestronk.com/corncob_caps.txt', 'dic.txt')"
REM to keep things clean, we clear the screen!
cls
REM The user probably already got bored, let's inform them that we're still working...
ECHO STILL WORKING...
REM wait what?!! The dictionary is all caps!! Lets fix that...
REM Lets loop through the file like so:

for /F "tokens=*" %%A in (dic.txt) do (
    SET "line=%%A"
    REM replace ALL the letters!!
    SET "line=!line:A=a!"
    SET "line=!line:B=b!"
    SET "line=!line:C=c!"
    SET "line=!line:D=d!"
    SET "line=!line:E=e!"
    SET "line=!line:F=f!"
    SET "line=!line:G=g!"
    SET "line=!line:H=h!"
    SET "line=!line:I=i!"
    SET "line=!line:J=j!"
    SET "line=!line:K=k!"
    SET "line=!line:L=l!"
    SET "line=!line:M=m!"
    SET "line=!line:N=n!"
    SET "line=!line:O=o!"
    SET "line=!line:P=p!"
    SET "line=!line:Q=q!"
    SET "line=!line:R=r!"
    SET "line=!line:S=s!"
    SET "line=!line:T=t!"
    SET "line=!line:U=u!"
    SET "line=!line:V=v!"
    SET "line=!line:W=w!"
    SET "line=!line:X=x!"
    SET "line=!line:Y=y!"
    SET "line=!line:Z=z!"
    ECHO !line! >> dic-tmp.txt
)

REM to keep things clean, we clear the screen!
cls
REM The user probably already got bored, let's inform them that we're still working...
:lookup
ECHO WOW! THAT TOOK LONG! ALMOST THERE...
REM Alright, now we need to find the correct date in the dictionary, we might need the users help in this...
REM Lets loop through ALL the lines again
set match=seriously?
for /F "tokens=*" %%a in (dic-tmp.txt) do (
    SET "line=%%a"
    REM to keep things clean, we clear the screen!
    cls
    REM replace the user input with some other stuff...
    SET "test=!line:%abbreviatedUserInput%=lol!"
    REM if the original line does not equal the test variable, then we have a match!
    IF NOT !line!==!test! (
        REM ask the user if the match is correct..
        set /P variableThatIsUsedForConfirmation= "Did you mean !line!? (Y/N): "
        REM if the user entered "y"
        IF /i {!variableThatIsUsedForConfirmation!}=={y} (
            REM set the variable "match" to the current line and goto the matchFound section...
            set match=!line!
            goto :matchFound
        )
    )
)
:matchFound
REM to keep things clean, we clear the screen!
cls
REM give the user their match
Echo Here's your month's full name: %match%
PAUSE
:hell
ECHO screw you!

Trollz

- Batch... - Downloading a list of words, because we can't type out the months manually... - Not using switch case hack - VERY SLOW - converting the text file to lowercase and saving it in another file - run it a second time without deleting the text files created and it will be even slower - Something ticks the script off while converting the dic.txt file to lowercase, this sets echo back on - This spoiler thing has messed up formatting by the way...