Sunday, 23 June 2019

Batch: Command line arguments


Command line arguments are passed to the batch command, based on the arguments passed, batch command takes specific action.

For example, when you execute the command ‘dir’, it lists all the files in a directory.

C:\Users\Public\databases>dir
 Volume in drive C is OSDisk
 Volume Serial Number is 1034-4F6F

 Directory of C:\Users\Public\databases

08/07/2018  09:28 PM    <DIR>          .
08/07/2018  09:28 PM    <DIR>          ..
08/07/2018  09:35 PM    <DIR>          batch script tutorial
02/10/2017  09:17 AM               436 customerDb.properties
02/10/2017  09:17 AM        52,887,096 customerDb.script
08/07/2018  09:28 PM    <DIR>          testApp
               2 File(s)     52,887,532 bytes
               4 Dir(s)  24,016,216,064 bytes free


You can lists all the directories in a specific directory by passing the directory name as command line argument.

C:\Users\Public\databases>dir testApp
 Volume in drive C is OSDisk
 Volume Serial Number is 1034-4F6F

 Directory of C:\Users\Public\databases\testApp

08/07/2018  09:28 PM    <DIR>          .
08/07/2018  09:28 PM    <DIR>          ..
               0 File(s)              0 bytes
               2 Dir(s)  24,014,905,344 bytes free

C:\Users\Public\databases>



Previous                                                 Next                                                 Home

No comments:

Post a Comment