Squash (Gast) - 17. Feb, 22:36

Exclamation

Gave your idea a try thinking the same would hold true for an exclamation.
SET STR="%~1"
ECHO This is my parameter: !STR:~1,-1!.

But if your data has an exclamation in it, it will get rid of the exclamation in the data. The only way to echo an exclamation is to turn off expansion. But I can't do that because I have to use it to do other things in my batch file.

I have a batch file that combines all files into one file but at the same time it appends the original filename it came from to the end of each line.

This is the main portion of my batch file
@echo off & setlocal enableextensions enabledelayedexpansion
Set _Opsheet=appendlog.log
set _Tcount=0
FOR /F "tokens=*" %%A IN ('dir /b /a-d *.TXT') DO (
set _count=0
set _Tfile=%%~nA .
set _Filename=!_Tfile:~0,15!
echo "Working on file: %%~nA"
FOR /F "Delims=" %%B IN (%%A) DO (
set /a _count+=1
set _tmpstr="%%B"
echo !_tmpstr:~1,-1!!_Filename! >> FILES_COMBINED.tmp
)
echo.!_Filename! count is !_count! >>%_Opsheet%
set /a _Tcount=!_Tcount!+!_count!
)
echo.Input Count is !_Tcount! >>%_Opsheet%

cypressor - 12. Jun, 20:57

Re: Exclamation

Try use SETLOCAL around the echo:

SETLOCAL DISABLEDELAYEDEXPANSION
ECHO.%_tmpstr:~1,-1%%_Filename% >> FILES_COMBINED.tmp
ENDLOCAL
jeb (Gast) - 26. Aug, 21:37

Output of exclamation marks

Exclamation marks CAN also be output with enabled delayed expansion.
The problem in your case is not the output, it's the assignment!
set "STR=%~1"
First the %1 expands to ex. "Hello!"
But then the parser tries to expand the single exclamation mark, this results in removing of the exclamation mark.

So it is enough to enable the delayed expansion after the SET-statement.

SET "STR=%~1"
setlocal EnableDelayedExpansion
ECHO This is my parameter: !STR:~1,-1!.

Name

Url

Meine Eingaben merken?

Titel:

Text:


JCaptcha - du musst dieses Bild lesen können, um das Formular abschicken zu können
Neues Bild

 

Reflog

Informationstechnische Howtos, Hinweise und Merkwürdiges

Batchlib v1.0 2008-03-29

Aktuelle Beiträge

HOWTO_ O2 DSL Surf &...
Der O2 DSL Surf & Phone-Router ist für die alleinige...
cypressor - 12. Feb, 19:57
Uptweak Windows XP Home...
There are a lot of annoying limitations in Windows...
cypressor - 9. Okt, 19:30
BATCHLIB_ Batchlib package...
Download Batchlib package v1.0 (5 KB zip file) What...
cypressor - 29. Mär, 19:10
BATCHLIB_ Batchlib library...
The batchlib library string.cmd is part of the batchlib...
cypressor - 29. Mär, 18:10

Homepage Ticker

Links

Status

Online seit 6784 Tagen
Zuletzt aktualisiert: 28. Jun, 11:32
RSS XML 1.0 Button-Get-Firefox

batch
batchlib
howto
tech
video
Profil
Abmelden
Weblog abonnieren