Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Character limit on variables within bat files  (Read 2067 times)

0 Members and 1 Guest are viewing this topic.

rkvalvog

  • Guest
Character limit on variables within bat files
« on: July 11, 2006, 10:33:09 AM »
I want to know if there is a way to limit the number of characters on an input variable within a .bat file. Using the %1 command to read in a variable, I want to limit this variable to 8 characters.
example: test.bat is the name of the bat file and within the bat file there is the following command:
SET name=%1

c:\>test 123456789

I would like name to be equal to 12345678 rather than 123456789.

Any help is appreciated, thanks.

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: Character limit on variables within bat files
« Reply #1 on: July 11, 2006, 10:49:29 AM »
This may be helpful:

Code: [Select]
set name=%1
set name=%name:~0,8%

 8-)
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

bobncat

  • Guest
Re: Character limit on variables within bat files
« Reply #2 on: July 11, 2006, 11:11:48 AM »
ok, this has nothing to do with your question, so please forgive me.

I have gone brain dead today.  I was sent a word file that is password protected.  I know I can remove the password protect from the word file but I am having a brain burp and can't for the life of me remember how.  I saved it to a floppy file.  I need to remove the password protect to use it as a working copy for a report I am processing.  Please help me and forgive the intrusion.  :)