Windows Batch Script

From PKC
Revision as of 13:11, 18 August 2021 by Benkoo (talk | contribs) (→‎FOR /L)
Jump to navigation Jump to search

Windows Batch Script is a crucial instrument for setting up PKC on Windows 10 platform.

Useful Websites

  1. Batch Script Tutorial on Tutorial Point
  2. Batch File to Create Formatted Date and Time
  3. Batch File Programming

Useful Hints

The following special expressions or characters may be useful in understanding Batch Script:

SET /A

SET varibale_name=variable_value
:: for assigning numeric value
SET /A variable_name=nameric_value

‘/A’ is used for assigning numeric values. Uninitialized variables are empty strings in batch files.

FOR /L

FOR /L %%var_name IN (Lowerlimit, Increment, Upperlimit) Do some_code
  • ‘/L’ signifies that for loop is used for iterating through a range of integer values.
  • Lower limit is the value from which loop will start until it reaches the Upper limit and the increment is the value with which lower limit will be increased during each iteration

FOR /D

FOR /D %y IN (C:\movie\*) DO @ECHO %y
  • For looping through directories, ‘/D' is used. It is illustrated in the above example.