Accessing Folder names with a space

Dell / Optiplex gx270...
October 14, 2009 at 01:50:51
Specs: Windows XP, 2.992 GHz / 1021 MB
The code below tries ti access a file from the folder , and the folder name has space and hence i dont get any output or error message... nothin jus happens... if i place the file in anyother folder that has spaces inbetween then it works totally fine . I tried double quotes also but without any change.Can you please let me know the reason and suggest an alternate.

@echo off > newfile & setLocal enableDELAYedexpansion

set N=
for /f "tokens=* delims= " %%a in (C:\Data\test rest pans\myfile) do (
set /a N+=1
)
set /a X=!N!-10
set N=

for /f "tokens=* delims= " %%a in (C:\Data\test rest pans\myfile) do (
set /a N+=1
if !N! gtr !X! echo %%a >> newfile
)


See More: Accessing Folder names with a space

Report •


#1
October 14, 2009 at 02:31:19
for /f "usebackq tokens=* delims= " %%a in ("C:\Data\test rest pans\myfile") do (

Without usebackq double quotes are interpreted as literal strings.

see "start > run > cmd > for /?" for more info.


Batch Variable how to


Report •

#2
October 14, 2009 at 02:42:29
Quotes doesnt work... its is not takin up the file ...

Report •

#3
October 14, 2009 at 02:55:13
Did you use the "usebackq" option that I mentioned above?


Batch Variable how to


Report •

Related Solutions

#4
October 14, 2009 at 03:39:41
yes ... the usebackq is wrking perfectly thanks a lot !!

Report •


Ask Question