Posts

Showing posts with the label batch-file

Batch Script to compare data

Batch Script to compare data Every day in my team a group of people extract a report from a portal and name it like ABC_23MAY2018.txt , XYZ_23MAY2018.txt and save it in a directory. ABC_23MAY2018.txt XYZ_23MAY2018.txt But because it is a manual process people do mistake like they extract the report of 22MAY2018 (giving the wrong date on the portal input) and name it ABC_23MAY2018.txt etc. This has caused of lots of issues as the file is used for reports purposes. I was thinking to create a batch script which will extract the date from the file name - 23MAY2018 and compare it with the date which will be extracted in another file date.txt. I have figured out to extract the date from file name : 22MAY2018 ABC_23MAY2018.txt 23MAY2018 set Filedate=ABC*.csv for /f %%A in ('dir /b %Filedate%') do ( set filename=%%~A set fileCSV=!filename:~9,10! echo !filename:~9,10! ) But how to compare it with the date in the file. for example, after extracting the date from filename its ...

How to set environment variables with spaces?

How to set environment variables with spaces? I need to set values to a environmental variable using a batch file. I wrote the script for this: @echo off set value="Hello world" setx -M srijani "%srijani%;%value%" It gives the error: ERROR: Invalid syntax. Default option is not allowed more than '2' time(s). Type "SETX /?" for usage. I googled and found that while using white spaces we need to write it inside a double quotes. set value="Hello world" But, that is not working too. Note: I am on Windows 7. what are the values of %srijani% and %value% variables. – npocmaka Dec 18 '15 at 10:35 %srijani% %value% Standard mistake often made is using set variable="value" instead of set "variable=value" . See for example Why is no string output wit...