Computing.Net > Forums > Windows Server 2003 > Batch File Scripting - Truncating

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch File Scripting - Truncating

Reply to Message Icon

Name: MooCow
Date: November 5, 2005 at 21:46:04 Pacific
OS: Win2k3
CPU/Ram: N/A
Comment:

For my purposes, I need to truncate a variable.
For example:
Var1 = AT1ABC
I need an ending result that will become:
Var1 = AT

Is there a truncate (or similar) command available?



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: November 5, 2005 at 21:54:42 Pacific
Reply:

:: setVar1.bat
@echo off

set Var1=AT1ABC
echo %Var1%
set Var1=%Var1:~0,2%
echo %Var1%
:: DONE

Note that spaces are significant, so:

set Var1=AT1ABC

is NOT the same as:

set Var1 = AT1ABC



If at first you don't succeed, you're about average.

M2


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Windows Server 2003 Forum Home


Sponsored links

Ads by Google


Results for: Batch File Scripting - Truncating

Batch File Problem! www.computing.net/answers/windows-2003/batch-file-problem/5941.html

Execute batch file on reboot www.computing.net/answers/windows-2003/execute-batch-file-on-reboot/7057.html

Active Directory Batch Files www.computing.net/answers/windows-2003/active-directory-batch-files/4757.html