0

I am absolutely new to Batch and my manager needs me to do this by end of the day, any help will be great.

In my below code, I am trying to read a CSV file which has a list of stores and corresponding IP addresses. I have written this code to read every IP address and add the IP in my path to get the last modified date of the specific .truststore file.

SET csvfile=C:\***\***\**\ip.csv

FOR /F "tokens=1-2* delims=," %%A in (%csvfile%) 
do (
rem if "%%~A" == "13" echo %%~B

SET store_num=%%~A

SET path1=%%~B & SET filename=\\%path1%\c$\***\***\**\*.truststore

net use X: %filename% /user:someuser password:password

FOR %%f IN (%filename%) DO SET filedatetime=%%~tf

IF "%filedatetime:~0,-9%" == "05/01/2015" GOTO END

echo %%A %%B %filedatetime% >> test.log )

-Somehow my filename always has the last IP address as the "path1" therefore it does not go to the other store's servers paths

-My last modified date is coming as empty(it was coming fine when I was doing for only one IP address and putting it manually)

-I am trying to match my last modified date and I found this way of removing the time so I did this:

IF "%filedatetime:~0,-9%" == "05/01/2015" GOTO END

What I am expecting as my result is: Store_num IP address Last Modified date

of only those stores whose .truststore file's last modified date is not 05/01/2015

Any help will be highly valuable.

Thank you!

Jini
  • 11
  • 3
  • 2
    So your problem is that the variables that you're setting inside of a `for` loop aren't updating? [Hmmm...](https://stackoverflow.com/questions/9681863/windows-batch-variables-wont-set) – SomethingDark Aug 16 '17 at 01:22
  • yes, only first set statement is getting updated and somehow the path1 gets the last IP address from the excel file. – Jini Aug 16 '17 at 02:08
  • 2
    Sorry, let me rephrase that. [coughcoughdelayedexpansioncoughcough](https://stackoverflow.com/questions/9681863/windows-batch-variables-wont-set) – SomethingDark Aug 16 '17 at 03:13
  • 2
    are you expecting **three-asterisks** to mean "any value" or are you using this mechanism to obscure the actual directoryname? – Magoo Aug 16 '17 at 06:31

0 Answers0