Используйте такой код:
Код:
@rem @set filename=c:\qweqweqwe\qweqweqwe\qweqweqwe\qweqwe.zip\fsdfsd\qweqweqw\r.doc
@if "%*"=="" goto usage
@set filename=%*
@set findpath=
@set ok=
@goto start
:sub3
@if "%findpath%"=="" goto first
@set findpath=%findpath%\%*
@goto next
:first
@set findpath=%*
:next
@echo %* | 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,20) DO @call :sub %%z
@if "%ok%"=="ok" @goto heyho
@echo Pattern ".zip" is not found.
@goto :EOF
:heyho
@echo %findpath%
@goto :EOF
:usage
@echo Usage: stripname.bat filename\...\filename.zip\filename\...