- Batch Script Tutorial
- Batch Script - Home
- Batch Script - Overview
- Batch Script - Environment
- Batch Script - Commands
- Batch Script - Files
- Batch Script - Syntax
- Batch Script - Variables
- Batch Script - Comments
- Batch Script - Strings
- Batch Script - Arrays
- Batch Script - Decision Making
- Batch Script - Operators
- Batch Script - DATE & TIME
- Batch Script - Input / Output
- Batch Script - Return Code
- Batch Script - Functions
- Batch Script - Process
- Batch Script - Aliases
- Batch Script - Devices
- Batch Script - Registry
- Batch Script - Network
- Batch Script - Printing
- Batch Script - Debugging
- Batch Script - Logging
- Batch Script Resources
- Batch Script - Quick Guide
- Batch Script - Useful Resources
- Batch Script - Discussion
Batch Script - Align Right
This used to align text to the right, which is normally used to improve readability of number columns.
Example
@echo off set x = 1000 set y = 1 set y = %y% echo %x% set y = %y:~-4% echo %y%
A few key things to note about the above program is −
Spaces are added to the variable of y, in this case we are adding 9 spaces to the variable of y.
We are using the ~-4 option to say that we just want to show the last 4 characters of the string y.
Output
The above command produces the following output. The key thing to note is that the value of 2 is aligned to match the units columns when displaying numbers.
1000 1
batch_script_strings.htm
Advertisements