Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extract first character from a string

I've no knowledge regarding Windows batch programming syntax. I have a text file containing user IDs which I need to delete using curl command and for that I need to extract first character of every user ID and then pass to the curl command. I know the curl command which will require two variables:

  1. 'UserID' - Read from the text file.
  2. 'firstCharacter' - Extracting first character from the User ID.

Below is the code to fetch user IDs from users.txt file:

@echo off
for /f "tokens=*" %%a in (symantecUsers.txt) do call :processline %%a
pause
goto :eof
:processline
echo %*
goto :eof
:eof

Please help me with extracting the first character from the read User IDs. Thanks.

like image 294
Jineet Vora Avatar asked Apr 26 '16 06:04

Jineet Vora


1 Answers

The cmd.exe can do a limited amount of string parsing. JosefZ gave you a good place to start.

C:>echo %PROCESSOR_ARCHITECTURE%
AMD64

C:>echo %PROCESSOR_ARCHITECTURE:~0,1%
A
like image 95
lit Avatar answered Oct 09 '22 14:10

lit