Using a Variable to trim another variable?
Posted: 24 Apr 2010 17:35
Hi, hope you can help me with this... hopefully should be an easy one!
I'm trying to write a batch file but I'm having problem trying to use the VALUE of a Variable in a 'Trim' function.
I have variable "BackupDir" which needs right-trimming by x amount. Amount x is defined by a variable "Length".
To do it by a fixed amount (trim 2 from the left and x from the right) I'd do:
%BackupDir:~2,-x%
But... how do I trim it by the value of "Length" ? An example below... but in reality the value of Length will change.
Set Length=11
Set BackupDir=%BackupDir:~2,- [%Length%] %
- I want this to do: BackupDir=%BackupDir:~2,-11%
Any ideas?
I'm trying to write a batch file but I'm having problem trying to use the VALUE of a Variable in a 'Trim' function.
I have variable "BackupDir" which needs right-trimming by x amount. Amount x is defined by a variable "Length".
To do it by a fixed amount (trim 2 from the left and x from the right) I'd do:
%BackupDir:~2,-x%
But... how do I trim it by the value of "Length" ? An example below... but in reality the value of Length will change.
Set Length=11
Set BackupDir=%BackupDir:~2,- [%Length%] %
- I want this to do: BackupDir=%BackupDir:~2,-11%
Any ideas?