Answers for "trim all space in bact file"

0

trimspace in bact file

@echo off 
set str = This string    has    a  lot  of spaces 
echo %str% 

set str=%str:=% 
echo %str%
Posted by: Guest on October-20-2020
0

trim all space in bact file

@echo off
setlocal EnableDelayedExpansion
set S=  This  is  a  test
echo %S%.
for /f "tokens=* delims= " %%a in ('echo %S%') do (set b=%%a & set b=!b: =_! & echo !b!)
endlocal & goto :EOF
Posted by: Guest on October-20-2020
0

trim all space in bact file

@ECHO OFF
  SETLOCAL ENABLEDELAYEDEXPANSION

  SET /p NAME=- NAME ? 
  ECHO "%NAME%"
  CALL :TRIM NAME
  ECHO "%NAME%"
  GOTO :EOF

  :TRIM
  SetLocal EnableDelayedExpansion
  Call :TRIMSUB %%%1%%
  EndLocal & set %1=%tempvar%
  GOTO :EOF

  :TRIMSUB
  set tempvar=%*
  GOTO :EOF
Posted by: Guest on October-20-2020
0

trim all space in bact file

:Trim
SetLocal EnableDelayedExpansion
set Params=%*
for /f "tokens=1*" %%a in ("!Params!") do EndLocal & set %1=%%b
exit /b
Posted by: Guest on October-20-2020

Browse Popular Code Answers by Language