문제

i am trying to Unrar 400 files via batch script. in my folder files mixed with videos some file name is "love.blood.repack.mp4" i have add .r for find rar file in my script but script show with videos file like "love.blood.repack.mp4"

how to check if extension have .rar .r001 .r01 .r02 etc and then run unrar ? only check extension not full file name

c:\unrar.bat c:\mymixedfolder

My windows .bat batch script

@echo off &setlocal
set /a nfile=0
echo Copying directory structure from %1 to %2 ...
xcopy /T "%~1" "%~2"
REM walk directory structure and convert each file in quiet mode
set "sourcefolder=%~1"
set "targetfolder=%~2"
for /R "%sourcefolder%" %%a in (*.r*) do (
    echo converting "%%~nxa" ...
    set "sourcefile=%%~fa"
    set "sourcepath=%%~dpa"
    set "targetfile=%%~na.flv"
    setlocal enabledelayedexpansion
    set "targetfolder=%targetfolder%!sourcepath:%sourcefolder%=!"
    echo "%%~nxa"
    endlocal
    set /A nfile+=1
)
echo Done! Unrar %nfile% file(s)
도움이 되었습니까?

해결책

try:

@ECHO OFF &SETLOCAL disableDelayedExpansion
SET "sourcefolder=."
FOR /R "%sourcefolder%" %%a IN (*.r*) DO (
    FOR /f "delims=" %%b IN ('echo %%~xa^|findstr /r "\.r.*"') DO ECHO %%~a
)

다른 팁

Here is another option:

@ECHO OFF
SET "sourcefolder=."
FOR /R "%sourcefolder%" %%a IN (*.r??) DO (
    if /i "%%~xa"==".rar" DO ECHO %%~a
)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top