My favorites
▼
|
Sign in
cmd-bat
CMD/BAT scripts for WinNT platforms
Project Home
Downloads
Wiki
Issues
Source
Checkout
Browse
Changes
Source path:
svn
/
trunk
/
libs
/
fs.basename.bat
‹r17
r30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
:: Print a dirname for the specified argument with trailing "\"
::
:: @param string The argument to be parsed
:: @param string The variable to store the resulting value
:dirname
setlocal
call :parse_filename_0 d1 d2 d3 d4 "%~dpnx1"
set d=%d1%%d2%
goto basename_0
:: Print a filename only for the specified argument
::
:: @param string The argument to be parsed
:: @param string The variable to store the resulting value
:basename
setlocal
call :parse_filename_0 d1 d2 d3 d4 "%~dpnx1"
set d=%d3%%d4%
:basename_0
if "%~2" == "" (
echo.%d%
endlocal
goto :EOF
)
endlocal && set %~2=%d%
goto :EOF
:: Stores al parts of a argument separately.
:: All arguments are mandatory.
::
:: @param string The variable for a drive
:: @param string The variable for a dirname
:: @param string The variable for a filename
:: @param string The variable for a extension
:: @param string The argument to be parsed
:parse_filename
call :parse_filename_0 "%~1" "%~2" "%~3" "%~4" "%~dpnx5"
goto :EOF
:parse_filename_0
if "%~5" == "" (
call :parse_filename_0 "%~1" "%~2" "%~3" "%~4" "."
goto :EOF
)
setlocal
set p=%~5
if "%p:~-1%" == "\" (
if "%p:~-2,-1%" == "" (
goto parse_filename_1
)
if "%p:~-2,-1%" == ":" (
goto parse_filename_1
)
endlocal && call :parse_filename_0 "%~1" "%~2" "%~3" "%~4" "%p:~0,-1%"
goto :EOF
)
:parse_filename_1
endlocal && set %~1=%~d5&& set %~2=%~p5&& set %~3=%~n5&& set %~4=%~x5
goto :EOF
Show details
Hide details
Change log
r18
by Ildar.Shaimordanov on Feb 12, 2010
Diff
[No log message]
Go to:
/trunk/libs/fs.basename.bat
/trunk/libs/fs.pwd.bat
Project members,
sign in
to write a code review
Older revisions
r17
by Ildar.Shaimordanov on Feb 12, 2010
Diff
[No log message]
r16
by Ildar.Shaimordanov on Feb 12, 2010
Diff
[No log message]
r15
by Ildar.Shaimordanov on Feb 12, 2010
Diff
[No log message]
All revisions of this file
File info
Size: 1560 bytes, 73 lines
View raw file
Powered by
Google Project Hosting