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

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -