-
Notifications
You must be signed in to change notification settings - Fork 9
/
dc.bat
49 lines (39 loc) · 1.03 KB
/
dc.bat
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
@setlocal EnableDelayedExpansion
@echo off
if "%~1"=="/?" call :usage && endlocal && exit /B 0
if "%~1"=="help" call :usage && endlocal && exit /B 0
if "%~1"=="--help" call :usage && endlocal && exit /B 0
set _spec=
set _args=
:parse
if "%~1"=="" goto :main
set arg=%~1
set firstChar=%arg:~0,1%
if "!firstChar!"=="/" (
set _args=%_args% %arg%
) else (
set _spec=*%~1*
)
shift
goto :parse
:main
rem left-trim the inputs
for /f "tokens=* delims= " %%a in ("!_args!") do set _args=%%a
for /f "tokens=* delims= " %%a in ("!_spec!") do set _spec=%%a
dir /on !_args! "!_spec!"
@endlocal
@exit /B 0
:usage
echo.
echo Lists files where name contains the value specified.
echo.
echo %~n0
echo lists all files.
echo %~n0 abc
echo lists files that contain `abc` in the name.
echo %~n0 [options] abc
echo lists files that contain `abc` in the name,
echo while also applying the specified options.
echo.
echo Created 2004-2013 @wasatchwizard
goto :eof