It's commonly done using an IF EXIST test.
Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
>is there any system available command to do that? or i have to analyze
>the path character by character?
>seems it's not that easy to judge a path is valid ,right?
Relative or absolute?
An absolute path will contain a : character or start with a \
1. the second and third characters are a colon and backslash
respectively
2. the first character is a backslash
--
Dean Wells [MVP / Directory Services]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l
"thinktwice" <memor...@gmail.com> wrote in message
news:313f430d-6da8-4865...@w5g2000prd.googlegroups.com...
--
Dean Wells [MVP / Directory Services]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l
"Esra Sdrawkcab" <ad...@127.0.0.1> wrote in message
news:QA2Uj.109012$Ff4....@newsfe5-win.ntli.net...
possibile forms of being a relative path
//relative path
..\somefolder
.\somefolder
..\somefolder\..\anotherfolder
do i miss any cases here?
\\.\c:\
... or
\\?\c:\
--
Dean Wells [MVP / Directory Services]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l
"thinktwice" <memor...@gmail.com> wrote in message
news:59fce814-30cc-4794...@h1g2000prh.googlegroups.com...
%VAR:~1,1%
... 1,1: starting char + chars
--
Dean Wells [MVP / Directory Services]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l
"thinktwice" <memor...@gmail.com> wrote in message
news:88489b3a-c424-478b...@l17g2000pri.googlegroups.com...
--
Dean Wells [MVP / Directory Services]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l
"Dean Wells (MVP)" <dwe...@maskmsetechnology.com> wrote in message
news:uGJuWV%23rIH...@TK2MSFTNGP02.phx.gbl...
by the way , could i analyze a literal string char by char ? seems for
loop could only process token by token
i didn't know \\.\c:\, \\?\c:\ could be valid path beofre. i have
tried these on my windows system, but seems the system doesn't
recognize these paths. are they linux related? by the way, i guess
dealing with popular forms is enough, if someone want to use the
special cases as u gave, i might tell them that's not supported :).
On May 7, 9:19 am, "Dean Wells \(MVP\)" <dwe...@maskmsetechnology.com>
wrote:
> The UNC path is a great addition and extends this scenario to
> non-locally mapped media; good point. I'd also add (albeit in
> hindsight) the edge-case examples below -
>
> \\.\c:\
>
> ... or
>
> \\?\c:\
>
> --
> Dean Wells [MVP / Directory Services]
> MSEtechnology
> [[ Please respond to the Newsgroup only regarding posts ]]
> R e m o v e t h e m a s k t o s e n d e m a i l
>
> "thinktwice" <memorial...@gmail.com> wrote in message
On May 7, 9:19 am, "Dean Wells \(MVP\)" <dwe...@maskmsetechnology.com>
wrote:
> The UNC path is a great addition and extends this scenario to
> non-locally mapped media; good point. I'd also add (albeit in
> hindsight) the edge-case examples below -
>
> \\.\c:\
>
> ... or
>
> \\?\c:\
>
> --
> Dean Wells [MVP / Directory Services]
> MSEtechnology
> [[ Please respond to the Newsgroup only regarding posts ]]
> R e m o v e t h e m a s k t o s e n d e m a i l
>
> "thinktwice" <memorial...@gmail.com> wrote in message
--
Dean Wells [MVP / Directory Services]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l
"thinktwice" <memor...@gmail.com> wrote in message
news:182aa84d-53cc-46ad...@q1g2000prf.googlegroups.com...
--
Dean Wells [MVP / Directory Services]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l
"thinktwice" <memor...@gmail.com> wrote in message
news:f02dba08-5c20-439c...@b9g2000prh.googlegroups.com...
set sPOS=%1
call echo %%PATH:~%sPOS%,1%%
--
Dean Wells [MVP / Directory Services]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l
"thinktwice" <memor...@gmail.com> wrote in message
news:f8560018-29c2-4ef9...@i36g2000prf.googlegroups.com...
Here's one way I can think of to parse a string ...
@echo off
set "string=%~1"
set "n="
:loop
if not defined string goto :EOF
set /a n+=1
set "char=%string:~0,1%"
set "string=%string:~1%"
echo %n% %char% %string%
goto loop
I thought if I knew the length of the string, it could also be done in
a FOR /L statement, but I couldn't find a good solution to the 'find
the length' problem in a google search. So, I constructed this
one ...
@echo off
echo.|set /p "x=%1" > %temp%\tmp.txt
for %%a in (%temp%\tmp.txt) do set Length=%%~za
del %temp%\tmp.txt
echo %Length%
So with the length the FOR parsing goes something like this ...
@echo off
echo.|set /p "x=%1" > %temp%\tmp.txt
for %%a in (%temp%\tmp.txt) do set /a c=%%~za-1
del %temp%\tmp.txt
set "string=%~1"
for /l %%a in (0,1,%c%) do call echo %%a %%string:~%%a,1%%
The looping solution seems a tiny bit more useful to me, but ...
set s=whatever
for /l %%c in (0,1,255) do (
set si=!s:~%%c!
WhateverYouWishToDoWithSi
)
All the best, Timo
--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:t...@uwasa.fi <http://www.uwasa.fi/~ts/> ; FI-65101, Finland
Useful CMD script tricks http://www.netikka.net/tsneti/info/tscmd.htm
:: 2 approaches below
:: ------------------------
:: FIRST
:: Example script that demonstrates how to count characters by piping
UNICODE output through
:: non-UNICODE console filters
@echo off
setlocal ENABLEDELAYEDEXPANSION
:: Space char. substitution below (I used a period) was necessary as
when %* or %VAR% is expanded by
:: the for-in-do below, it concatenated any number of sequential spaces
to 1 space destroying an
:: accurate count
set VAR=%*
set VAR=%VAR: =.%
if "%VAR%"=="" (
set CNT=0
) else (
for /f "delims=[] tokens=1" %%l in ('cmd /u /c echo %VAR%^| find /v /n
""') do (
set /a CNT=%%l-3
)
)
echo %CNT%
goto :EOF
:: -------------------------
:: SECOND
:: Uses byte size within a temporary file
:getLEN
set LENGTH=0
set /p=%1>%tempFILE%<nul
for /f %%l in ("%tempFILE%") do set LENGTH=%%~zl
goto :EOF
--
Dean Wells [MVP / Directory Services]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l
"Tom Lavedas" <tglb...@cox.net> wrote in message
news:f233d609-b206-46a0...@d1g2000hsg.googlegroups.com...
>but how could i analyze the path character by character? for loop
>seems could only process token by token
@echo off
set var=%1
echo %var%|find ":">nul&& echo path is absolute
echo %var%|findstr /r "^\\.*" >nul&& echo path is absolute