Rename filename to remove invalid characters?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Shohreh
Posts: 33
Joined: 26 Feb 2020 08:05

Rename filename to remove invalid characters?

#1 Post by Shohreh » 27 May 2023 00:43

Hello,

I'd like to use an HTML's title as filename, but it may contain invalid characters like question marks, etc.

Do you know of a way to rewrite a string so that it's DOS-legit?

Code: Select all

FOR /F "delims=" %%A IN ('xidel "%1" -se "title:=//title" --output-format cmd') DO %%A
echo %title%
wget -O "%title%.html" "%1"
Thank you.
--
Edit: One way I came across:

Code: Select all

SET title=%title: =_%
SET title=%title:?=%
echo %title%

Post Reply