length should be 8 characters

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
sivaram.nv
Posts: 4
Joined: 30 Aug 2007 02:29

length should be 8 characters

#1 Post by sivaram.nv » 30 Aug 2007 02:39

HI

I refered this URL to find 8 characters but not working properly

http://www.dostips.com/DtCodeFunctions. ... c128586394

My requirement is

set string=abcdefghijk (11 characters i have taken)

I need to count the 8 charactes only if it is more than 8 i need to skip

anybody can help me to sort out this issue

Thanks & Regards
Sivaram Nv

sivaram.nv
Posts: 4
Joined: 30 Aug 2007 02:29

#2 Post by sivaram.nv » 30 Aug 2007 11:19

Hi All

Please find solution for the below query

@echo off

REM the below mentioned str having more than 8 characters

set str=Sivaramnv

echo Given Queue Manager Nae %str%
set str1=%str:~0,8%
echo After 8 Strings the QM name is %str1%


set str2=%str%

set str2=%str2:~8%
echo After 8 Characters result of QM Name %str2%

set string01=%str1%
set string02=%str2%

set final_string=%string01%%string02%

echo total 2 strings(1st 8 and after 8) %final_string%

IF "%string02%" EQU "" GOTO START

GOTO STOP

:START
echo 8 character Qmanager Name is %final_string%
GOTO END


:STOP
echo You have exceeded more than 8 characters
GOTO END

:END

jeb
Expert
Posts: 1055
Joined: 30 Aug 2007 08:05
Location: Germany, Bochum

#3 Post by jeb » 30 Aug 2007 14:11

Hi,

nice, but where do you have a problem?

Your batch results in

1) set str=12345678
8 character Qmanager Name is 12345678

2) set str=123456789abcd
You have exceeded more than 8 characters

Which results do you want? :?:

Post Reply