Pergunta

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)
Foi útil?

Solução

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
)

Outras dicas

Here is another option:

@ECHO OFF
SET "sourcefolder=."
FOR /R "%sourcefolder%" %%a IN (*.r??) DO (
    if /i "%%~xa"==".rar" DO ECHO %%~a
)
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top