Spaces in Path causing a problem

View: New views
5 Messages — Rating Filter:   Alert me  

Spaces in Path causing a problem

by Gary Kuznitz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have a bat file that is giving me an error when there is a space in the
%path_List%.

The error is:
The system cannot find the file C:\Program.

How can I fix the bat file so spaces in the path will work?

@echo off

::I am using this batch file with the list of items to be defragged. The items
are categorised as
::hogs (h): put at the end of the disk
::specials (s): kept near the start of disk leaving 5% empty space before them
::ultras (u): kept near the start of disk leaving 1% empty space before them

::The first letter before the pipe symbol tells whether an item is hog, special
or ultra.

::Start /belownormal /wait C:\Batch\CleanTemp2.bat
setlocal ENABLEDELAYEDEXPANSION

set EXE=JkDefrag.exe
rem set EXE=JkDefragCmd.exe

set DEBUG_LEVEL=3

rem a 7 is sort by name
rem a 3 is Defragment and fast optimize

set DEFRAG_MODE=3

set PATH_BIN=%~dp0
set PATH_LIST=%PATH_BIN%JKDefragDefrag-list.txt


set SPEED_VALUE=100
set SPEED=
if not %SPEED_VALUE%==100 set SPEED= -s %SPEED_VALUE%


set EXE=%PATH_BIN%\%EXE%

fsutil.exe usn deletejournal /D C:

set specials=
FOR /F "eol=; tokens=1,2 delims=|" %%i in (%PATH_LIST%) do if "%%i"=="s" set
specials=!specials! "%%j"

set specials_excludes=
FOR /F "eol=; tokens=1,2 delims=|" %%i in (%PATH_LIST%) do if "%%i"=="s" set
specials_excludes=!specials_excludes! -e "%%j"

set hogs=
FOR /F "eol=; tokens=1,2 delims=|" %%i in (%PATH_LIST%) do if "%%i"=="h" set
hogs=!hogs! "%%j"

set hogs_excludes=
FOR /F "eol=; tokens=1,2 delims=|" %%i in (%PATH_LIST%) do if "%%i"=="h" set
hogs_excludes=!hogs_excludes! -e "%%j"

set ultras=
FOR /F "eol=; tokens=1,2 delims=|" %%i in (%PATH_LIST%) do if "%%i"=="u" set
ultras=!ultras! "%%j"

set ultras_excludes=
FOR /F "eol=; tokens=1,2 delims=|" %%i in (%PATH_LIST%) do if "%%i"=="u" set
ultras_excludes=!ultras_excludes! -e "%%j"


Start /belownormal /wait %EXE% -d %DEBUG_LEVEL% -l "" -q %SPEED% -f 5 -a 6 -u
DisableDefaults %hogs%
Start /belownormal /wait %EXE% -d %DEBUG_LEVEL% -l "" -q %SPEED% -f 1 -a 3 -u
DisableDefaults  %hogs_excludes% %specials_excludes% %ultras%

Start /belownormal /wait %EXE% -d %DEBUG_LEVEL% -l "" -q %SPEED% -f 5 -a 3 -u
DisableDefaults %hogs_excludes% %ultras_excludes% %specials%
Start /belownormal /wait %EXE% -d %DEBUG_LEVEL% -l "" -q %SPEED% -f 15 -a 3 -u
DisableDefaults %hogs_excludes% %specials_excludes% %ultras_excludes% c:\*.*

fsutil.exe usn createjournal m=0 a=0 C:



Parent Message unknown Re: Spaces in Path causing a problem

by habs3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Gary

The path needs to be put in quotes. so try"%path_list%" or %"path_list"%. see if that will work. Worth a shot.


----- Original Message ----
From: Gary Kuznitz <docfxit@...>
To: batchworld@...
Sent: Thursday, May 15, 2008 1:24:59 PM
Subject: [BATCH WORLD] Spaces in Path causing a problem


I have a bat file that is giving me an error when there is a space in the
%path_List%.

The error is:
The system cannot find the file C:\Program.

How can I fix the bat file so spaces in the path will work?

@echo off

::I am using this batch file with the list of items to be defragged. The items
are categorised as
::hogs (h): put at the end of the disk
::specials (s): kept near the start of disk leaving 5% empty space before them
::ultras (u): kept near the start of disk leaving 1% empty space before them

::The first letter before the pipe symbol tells whether an item is hog, special
or ultra.

::Start /belownormal /wait C:\Batch\CleanTemp2 .bat
setlocal ENABLEDELAYEDEXPANS ION

set EXE=JkDefrag. exe
rem set EXE=JkDefragCmd. exe

set DEBUG_LEVEL= 3

rem a 7 is sort by name
rem a 3 is Defragment and fast optimize

set DEFRAG_MODE= 3

set PATH_BIN=%~dp0
set PATH_LIST=%PATH_ BIN%JKDefragDefr ag-list.txt

set SPEED_VALUE= 100
set SPEED=
if not %SPEED_VALUE% ==100 set SPEED= -s %SPEED_VALUE%

set EXE=%PATH_BIN% \%EXE%

fsutil.exe usn deletejournal /D C:

set specials=
FOR /F "eol=; tokens=1,2 delims=|" %%i in (%PATH_LIST% ) do if "%%i"=="s" set
specials=!specials! "%%j"

set specials_excludes=
FOR /F "eol=; tokens=1,2 delims=|" %%i in (%PATH_LIST% ) do if "%%i"=="s" set
specials_excludes= !specials_ excludes! -e "%%j"

set hogs=
FOR /F "eol=; tokens=1,2 delims=|" %%i in (%PATH_LIST% ) do if "%%i"=="h" set
hogs=!hogs! "%%j"

set hogs_excludes=
FOR /F "eol=; tokens=1,2 delims=|" %%i in (%PATH_LIST% ) do if "%%i"=="h" set
hogs_excludes= !hogs_excludes! -e "%%j"

set ultras=
FOR /F "eol=; tokens=1,2 delims=|" %%i in (%PATH_LIST% ) do if "%%i"=="u" set
ultras=!ultras! "%%j"

set ultras_excludes=
FOR /F "eol=; tokens=1,2 delims=|" %%i in (%PATH_LIST% ) do if "%%i"=="u" set
ultras_excludes= !ultras_excludes ! -e "%%j"

Start /belownormal /wait %EXE% -d %DEBUG_LEVEL% -l "" -q %SPEED% -f 5 -a 6 -u
DisableDefaults %hogs%
Start /belownormal /wait %EXE% -d %DEBUG_LEVEL% -l "" -q %SPEED% -f 1 -a 3 -u
DisableDefaults  %hogs_excludes% %specials_excludes% %ultras%

Start /belownormal /wait %EXE% -d %DEBUG_LEVEL% -l "" -q %SPEED% -f 5 -a 3 -u
DisableDefaults %hogs_excludes% %ultras_excludes% %specials%
Start /belownormal /wait %EXE% -d %DEBUG_LEVEL% -l "" -q %SPEED% -f 15 -a 3 -u
DisableDefaults %hogs_excludes% %specials_excludes% %ultras_excludes% c:\*.*

fsutil.exe usn createjournal m=0 a=0 C:

   


     

[Non-text portions of this message have been removed]


Re: Spaces in Path causing a problem

by Michael Burek :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You need double quotes around the path\file name.

Try changing
set PATH_BIN=%~dp0

to
set PATH_BIN="%~dp0"



On Thu, May 15, 2008 at 12:24 PM, Gary Kuznitz <docfxit@...> wrote:

>   I have a bat file that is giving me an error when there is a space in
> the
> %path_List%.
>
> The error is:
> The system cannot find the file C:\Program.
>
> How can I fix the bat file so spaces in the path will work?
>
> @echo off
>
> ::I am using this batch file with the list of items to be defragged. The
> items
> are categorised as
> ::hogs (h): put at the end of the disk
> ::specials (s): kept near the start of disk leaving 5% empty space before
> them
> ::ultras (u): kept near the start of disk leaving 1% empty space before
> them
>
> ::The first letter before the pipe symbol tells whether an item is hog,
> special
> or ultra.
>
> ::Start /belownormal /wait C:\Batch\CleanTemp2.bat
> setlocal ENABLEDELAYEDEXPANSION
>
> set EXE=JkDefrag.exe
> rem set EXE=JkDefragCmd.exe
>
> set DEBUG_LEVEL=3
>
> rem a 7 is sort by name
> rem a 3 is Defragment and fast optimize
>
> set DEFRAG_MODE=3
>
> set PATH_BIN=%~dp0
> set PATH_LIST=%PATH_BIN%JKDefragDefrag-list.txt
>
> set SPEED_VALUE=100
> set SPEED=
> if not %SPEED_VALUE%==100 set SPEED= -s %SPEED_VALUE%
>
> set EXE=%PATH_BIN%\%EXE%
>
> fsutil.exe usn deletejournal /D C:
>
> set specials=
> FOR /F "eol=; tokens=1,2 delims=|" %%i in (%PATH_LIST%) do if "%%i"=="s"
> set
> specials=!specials! "%%j"
>
> set specials_excludes=
> FOR /F "eol=; tokens=1,2 delims=|" %%i in (%PATH_LIST%) do if "%%i"=="s"
> set
> specials_excludes=!specials_excludes! -e "%%j"
>
> set hogs=
> FOR /F "eol=; tokens=1,2 delims=|" %%i in (%PATH_LIST%) do if "%%i"=="h"
> set
> hogs=!hogs! "%%j"
>
> set hogs_excludes=
> FOR /F "eol=; tokens=1,2 delims=|" %%i in (%PATH_LIST%) do if "%%i"=="h"
> set
> hogs_excludes=!hogs_excludes! -e "%%j"
>
> set ultras=
> FOR /F "eol=; tokens=1,2 delims=|" %%i in (%PATH_LIST%) do if "%%i"=="u"
> set
> ultras=!ultras! "%%j"
>
> set ultras_excludes=
> FOR /F "eol=; tokens=1,2 delims=|" %%i in (%PATH_LIST%) do if "%%i"=="u"
> set
> ultras_excludes=!ultras_excludes! -e "%%j"
>
> Start /belownormal /wait %EXE% -d %DEBUG_LEVEL% -l "" -q %SPEED% -f 5 -a 6
> -u
> DisableDefaults %hogs%
> Start /belownormal /wait %EXE% -d %DEBUG_LEVEL% -l "" -q %SPEED% -f 1 -a 3
> -u
> DisableDefaults %hogs_excludes% %specials_excludes% %ultras%
>
> Start /belownormal /wait %EXE% -d %DEBUG_LEVEL% -l "" -q %SPEED% -f 5 -a 3
> -u
> DisableDefaults %hogs_excludes% %ultras_excludes% %specials%
> Start /belownormal /wait %EXE% -d %DEBUG_LEVEL% -l "" -q %SPEED% -f 15 -a 3
> -u
> DisableDefaults %hogs_excludes% %specials_excludes% %ultras_excludes%
> c:\*.*
>
> fsutil.exe usn createjournal m=0 a=0 C:
>
>  
>


[Non-text portions of this message have been removed]


RE: Spaces in Path causing a problem

by Morris, Lamar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You can also use progra~1 instead of program files

 

Lamar

 

________________________________

From: batchworld@... [mailto:batchworld@...] On
Behalf Of Michael Burek
Sent: Thursday, May 15, 2008 12:41 PM
To: batchworld@...
Subject: Re: [BATCH WORLD] Spaces in Path causing a problem

 

You need double quotes around the path\file name.

Try changing
set PATH_BIN=%~dp0

to
set PATH_BIN="%~dp0"

On Thu, May 15, 2008 at 12:24 PM, Gary Kuznitz <docfxit@...
<mailto:docfxit%40theoffice.la> > wrote:

> I have a bat file that is giving me an error when there is a space in
> the
> %path_List%.
>
> The error is:
> The system cannot find the file C:\Program.
>
> How can I fix the bat file so spaces in the path will work?
>
> @echo off
>
> ::I am using this batch file with the list of items to be defragged.
The
> items
> are categorised as
> ::hogs (h): put at the end of the disk
> ::specials (s): kept near the start of disk leaving 5% empty space
before
> them
> ::ultras (u): kept near the start of disk leaving 1% empty space
before
> them
>
> ::The first letter before the pipe symbol tells whether an item is
hog,

> special
> or ultra.
>
> ::Start /belownormal /wait C:\Batch\CleanTemp2.bat
> setlocal ENABLEDELAYEDEXPANSION
>
> set EXE=JkDefrag.exe
> rem set EXE=JkDefragCmd.exe
>
> set DEBUG_LEVEL=3
>
> rem a 7 is sort by name
> rem a 3 is Defragment and fast optimize
>
> set DEFRAG_MODE=3
>
> set PATH_BIN=%~dp0
> set PATH_LIST=%PATH_BIN%JKDefragDefrag-list.txt
>
> set SPEED_VALUE=100
> set SPEED=
> if not %SPEED_VALUE%==100 set SPEED= -s %SPEED_VALUE%
>
> set EXE=%PATH_BIN%\%EXE%
>
> fsutil.exe usn deletejournal /D C:
>
> set specials=
> FOR /F "eol=; tokens=1,2 delims=|" %%i in (%PATH_LIST%) do if
"%%i"=="s"
> set
> specials=!specials! "%%j"
>
> set specials_excludes=
> FOR /F "eol=; tokens=1,2 delims=|" %%i in (%PATH_LIST%) do if
"%%i"=="s"
> set
> specials_excludes=!specials_excludes! -e "%%j"
>
> set hogs=
> FOR /F "eol=; tokens=1,2 delims=|" %%i in (%PATH_LIST%) do if
"%%i"=="h"
> set
> hogs=!hogs! "%%j"
>
> set hogs_excludes=
> FOR /F "eol=; tokens=1,2 delims=|" %%i in (%PATH_LIST%) do if
"%%i"=="h"
> set
> hogs_excludes=!hogs_excludes! -e "%%j"
>
> set ultras=
> FOR /F "eol=; tokens=1,2 delims=|" %%i in (%PATH_LIST%) do if
"%%i"=="u"
> set
> ultras=!ultras! "%%j"
>
> set ultras_excludes=
> FOR /F "eol=; tokens=1,2 delims=|" %%i in (%PATH_LIST%) do if
"%%i"=="u"
> set
> ultras_excludes=!ultras_excludes! -e "%%j"
>
> Start /belownormal /wait %EXE% -d %DEBUG_LEVEL% -l "" -q %SPEED% -f 5
-a 6
> -u
> DisableDefaults %hogs%
> Start /belownormal /wait %EXE% -d %DEBUG_LEVEL% -l "" -q %SPEED% -f 1
-a 3
> -u
> DisableDefaults %hogs_excludes% %specials_excludes% %ultras%
>
> Start /belownormal /wait %EXE% -d %DEBUG_LEVEL% -l "" -q %SPEED% -f 5
-a 3
> -u
> DisableDefaults %hogs_excludes% %ultras_excludes% %specials%
> Start /belownormal /wait %EXE% -d %DEBUG_LEVEL% -l "" -q %SPEED% -f 15
-a 3
> -u
> DisableDefaults %hogs_excludes% %specials_excludes% %ultras_excludes%
> c:\*.*
>
> fsutil.exe usn createjournal m=0 a=0 C:
>
>
>

[Non-text portions of this message have been removed]

 



[Non-text portions of this message have been removed]


Re: Spaces in Path causing a problem

by Gary Kuznitz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for the reply.

On 15 May 2008 at 10:40, habs3 (habs3 <batchworld@...>) commented about Re: [BATCH WORLD] Spaces in Path causing a proble:
> The path needs to be put in quotes. so try"%path_list%" or %"path_list"%. see if
> that will work. Worth a shot.
This worked.
 "%PATH_BIN%JKDefragDefrag-list.txt"
 "%PATH_BIN%%EXE%"

> ----- Original Message ----
> From: Gary Kuznitz <docfxit@...>
> To: batchworld@...
> Sent: Thursday, May 15, 2008 1:24:59 PM
> Subject: [BATCH WORLD] Spaces in Path causing a problem
>
>
> I have a bat file that is giving me an error when there is a space in the
> %path_List%.
>
> The error is:
> The system cannot find the file C:\Program.
>
> How can I fix the bat file so spaces in the path will work?
>
> @echo off
>
> ::I am using this batch file with the list of items to be defragged. The items
> are categorised as ::hogs (h): put at the end of the disk ::specials (s): kept
> near the start of disk leaving 5% empty space before them ::ultras (u): kept
> near the start of disk leaving 1% empty space before them
>
> ::The first letter before the pipe symbol tells whether an item is hog, special
> or ultra.
>
> ::Start /belownormal /wait C:\Batch\CleanTemp2 .bat
> setlocal ENABLEDELAYEDEXPANS ION
>
> set EXE=JkDefrag. exe
> rem set EXE=JkDefragCmd. exe
>
> set DEBUG_LEVEL= 3
>
> rem a 7 is sort by name
> rem a 3 is Defragment and fast optimize
>
> set DEFRAG_MODE= 3
>
> set PATH_BIN=%~dp0
> set PATH_LIST=%PATH_ BIN%JKDefragDefr ag-list.txt
>
> set SPEED_VALUE= 100
> set SPEED=
> if not %SPEED_VALUE% ==100 set SPEED= -s %SPEED_VALUE%
>
> set EXE=%PATH_BIN% \%EXE%
>
> fsutil.exe usn deletejournal /D C:
>
> set specials=
> FOR /F "eol=; tokens=1,2 delims=|" %%i in (%PATH_LIST% ) do if "%%i"=="s" set
> specials=!specials! "%%j"
>
> set specials_excludes=
> FOR /F "eol=; tokens=1,2 delims=|" %%i in (%PATH_LIST% ) do if "%%i"=="s" set
> specials_excludes= !specials_ excludes! -e "%%j"
>
> set hogs=
> FOR /F "eol=; tokens=1,2 delims=|" %%i in (%PATH_LIST% ) do if "%%i"=="h" set
> hogs=!hogs! "%%j"
>
> set hogs_excludes=
> FOR /F "eol=; tokens=1,2 delims=|" %%i in (%PATH_LIST% ) do if "%%i"=="h" set
> hogs_excludes= !hogs_excludes! -e "%%j"
>
> set ultras=
> FOR /F "eol=; tokens=1,2 delims=|" %%i in (%PATH_LIST% ) do if "%%i"=="u" set
> ultras=!ultras! "%%j"
>
> set ultras_excludes=
> FOR /F "eol=; tokens=1,2 delims=|" %%i in (%PATH_LIST% ) do if "%%i"=="u" set
> ultras_excludes= !ultras_excludes ! -e "%%j"
>
> Start /belownormal /wait %EXE% -d %DEBUG_LEVEL% -l "" -q %SPEED% -f 5 -a 6 -u
> DisableDefaults %hogs% Start /belownormal /wait %EXE% -d %DEBUG_LEVEL% -l "" -q
> %SPEED% -f 1 -a 3 -u DisableDefaults  %hogs_excludes% %specials_excludes%
> %ultras%
>
> Start /belownormal /wait %EXE% -d %DEBUG_LEVEL% -l "" -q %SPEED% -f 5 -a 3 -u
> DisableDefaults %hogs_excludes% %ultras_excludes% %specials% Start /belownormal
> /wait %EXE% -d %DEBUG_LEVEL% -l "" -q %SPEED% -f 15 -a 3 -u DisableDefaults
> %hogs_excludes% %specials_excludes% %ultras_excludes% c:\*.*
>
> fsutil.exe usn createjournal m=0 a=0 C:


LightInTheBox - Buy quality products at wholesale price