how to handle special characters in file names

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Ninon
Posts: 1
Joined: 06 Apr 2020 01:27

how to handle special characters in file names

#1 Post by Ninon » 06 Apr 2020 06:23

Hi there,

I have trouble to extract some data out of an single.txt file (the file name contains signs like: . and =).
The input (%1) is a txt files that contains all the single.txt files.

Somehow, the second for loop doesn't work...

Code: Select all

SETLOCAL ENABLEDELAYEDEXPANSION
if exist PJ_Overview.txt del PJ_Overview.txt

echo Writing output text file. Please wait - can take a few minutes...
echo.
echo file:

set /A _Anzahl=0
set "TAB=	"

for /f %%i in (%1) do (
	for /f "tokens=1,2" %%j in (%%i) do if [%%j]==[VERSION] (
	echo %%j>>PJ_Overview.txt
	)
	set /A _Anzahl += 1
	echo !_Anzahl!%TAB%%%i%TAB%%%j>>PJ_Overview.txt
)
Does anyone has a hint for me?
Thank you!

penpen
Expert
Posts: 2009
Joined: 23 Jun 2013 06:15
Location: Germany

Re: how to handle special characters in file names

#2 Post by penpen » 14 Apr 2020 04:53

The diagnosis "doesn't work" isn't helpfull:
So please provide sample files (minimum, representative and short examples) that produces the error and
specify what you expect to see and what the result of your code is, so we can test the effects of changes to the code.

penpen

Post Reply