IF Command Not Working? What Have I Done

VinzentValentyn

Reputable
Sep 22, 2015
2
0
4,510
Hi guys

So I have created a very simple batch file and all I want to do is check if the current date (from the OS) matches the date in the batch file.

I had it working once. Initially the command was IF date/t==22/09/2015 (goto x) else (goto y)

Then x and y were defined and it chose the correct one.

But now even the simple command of IF date/t==22/09/2015 ping google.com does not work

I get no error message or ping displayed. It just creates a new black line in the command prompt window.

IF Exist (filename) ping google.com works fine though for some reason.

But I really want to use the string comparison of IF. I have tried to use the date.exe from UNIX too as that date is output the same regardless of region but that doesn't work either.

Does anyone know why this isn't working? I've tried turning delayed expansion on and off (cmd /x and cmd /y) but it makes no difference.

I could be making a mistake somewhere as I'm not at all familiar with this command but hopefully someone can get this working in a batch file.

Alternatively is there a way to turn the output of a command into a filename? So for instance if I use the UNIX date.exe it will give me a date of 2015-09-22 then if I could create a text file with that name I could just use IF EXIST. But I don't gots the skills 🙁

Any help would be appreciated.
 
Okay guys I fee like such a noob.

So If I use the command IF NOT date/t==22/09/2015 start cmd (or any command) it completes the command.

But when I do date/t that is the text I get. Why is it saying the two are not the same?