Searching for redirection chars with findstr
Posted: 22 Jun 2012 17:53
Here is problematic code:
example of format.txt:
I am trying to error check in format.txt to see if the "format" contains illegal characters and to alert the user. Problem is when escape characters are encountered, I think the "echo %%a" line is exiting on error / creating files with strange names. How could I fix this? or is there another way to do this?
Code: Select all
for /f "tokens=* eol=/ delims=" %%a in (format.txt) do (
echo %%a|findstr /r "[/\:*?^"^<^>^|]" > nul
if errorlevel 1 (
set "format=%%a"
) else (
cls
echo Your format contains illegal characters!
echo Rename not completed.
pause
exit
)
)
example of format.txt:
Code: Select all
/ Formating tokens = [name],[ext],[mm],[dd],[yy],[yyyy],[hour],[min]
/ Illegal Characters: / \ : * ? " < > |
/ Format:
[name] [[mm]>[dd]].txt
I am trying to error check in format.txt to see if the "format" contains illegal characters and to alert the user. Problem is when escape characters are encountered, I think the "echo %%a" line is exiting on error / creating files with strange names. How could I fix this? or is there another way to do this?