batch script to rename a file with string (with space) from variable -
there file named doctitle.txt contains title. want use title rename file, name file.pdf, did:
for /f "delims=" %%x in (doctitle.txt) set "doctitle=%%x" move file.pdf %doctitle%.pdf
this works fine, if there no space in title string, i.e "documenttitle". fails if there space in title, i.e "document title".
what done overcome issue?
try:
for /f "tokens=*" %%x in (doctitle.txt) set doctitle=%%~x move file.pdf "%doctitle%.pdf"
that way, variable doctitle
not surrounded quotes %%~
removes quotes.
quoting for /?
:
%~i - expands %i removing surrounding quotes (")
Comments
Post a Comment