Код:
@if "%1"=="" goto usage
@set filename=%1
@set findpath=
@set ok=
@goto start
:sub3
@if "%findpath%"=="" goto first
@set findpath=%findpath%\%1
@goto next
:first
@set findpath=%1
:next
@echo %1 | find ".zip" >nul
@if "%errorlevel%"=="0" goto fook
@goto :EOF
:fook
@set ok=ok
@goto :EOF
:sub2
@FOR /F %1 %%i in ("%filename%") do @call :sub3 %%i
@goto :EOF
:sub
@if "%ok%"=="ok" @goto :EOF
@set v="eol=; tokens=%1* delims=\"
@call :sub2 %v%
@goto :EOF
:start
@FOR /L %%z IN (1,1,10) DO @call :sub %%z
@echo %findpath%
@goto :EOF
:usage
@echo Usage: stripname.bat filename\...\filename.zip\filename\...
Пример использования:
Код:
C:\Temp>stripname c:\123123.123123\123.zip\\123.12312.3\123\123\123.doc
c:\123123.123123\123.zip