:Set some variables, the string variable, a second string variable and our starting count.
set str=\\fileservertestserver\accounting\Budgets\Budgets 2012\2012 Budget GA Loads
:the loop works like so... we check to see if N has been incremented to 55 (our
:target number of characters). If it has, it goes to a new routine which creates
:our path. If it does not, we increment N by one then check to see if the string
:has reached a NULL character. If it has not reached "55" then goto loop and repeat.
if !N! equ 55 (
set /A N+=1
if "!str:~1!" neq "" (
:if string length exceeds 55 chars, take the first 25 chars and the last 25 chars with an ellipse (...)
Friday, November 18, 2011
Count Characters in a Batch File
I have an issue where I need to ensure I don't exceed a certain number of characters in a script. Specifically, I cannot exceed 64 characters while making a group through script in AD. To do this I came up with the following: