
Quote: Originally Posted by
Digital7
I want to modify 2 more things into this script...is there anyway to extract the File in same folder as all the rar files insted of making new folder .extracted ?
The below bat file will do this but if a RAR file contains a RAR file it will only extract the first RAR(s) and not any RAR's that are extracted from the first, that's beyond me.
Code:
@echo off
REM Usage
REM UnRAR.bat "%D" "%N" "%F" %K
REM %D (%1) = Directory where files are saved
REM %N (%2) = Display name of download
REM %F (%3) = Name of downloaded file (For single file torrents)
REM %K (%4) = Single/Multi
set WINRAR="C:\Program Files\WinRAR\UnRAR"
REM Strip quotes from %1, %2 and %3 to make it easier.
set FOLDER=%1
set FOLDER=%FOLDER:~1,-1%
set DISNAME=%2
set DISNAME=%DISNAME:~1,-1%
set FILENAME=%3
set FILENAME=%FILENAME:~1,-1%
REM Test if the directory where files are saved contains a RAR file
if not exist "%FOLDER%\*.rar" exit
if /i %4==Multi goto MULTI
REM -------------------------------------------------
:Single
REM Change the CMD prompt to the directory where files are saved.
cd /d "%FOLDER%"
%WINRAR% e -o- "%FOLDER%\%FILENAME%"
exit
REM -------------------------------------------------
:MULTI
REM For multi file torrent
REM Get first RAR's filename
REM Change the CMD prompt to the directory where files are saved.
for %%a in ("%FOLDER%\*.rar") do (
set "FILE=%%a"
cd /d "%FOLDER%"
goto :DONE
)
:DONE
%WINRAR% e -o- "%FILE%" 
Quote: Originally Posted by
Digital7
second question...is there a way to rename the file while it extracts to same as Rar file name...?
This is more difficult all I can say tonight is maybe. The only problem is if the RAR contains more than one file, eg. a text, checksum or nfo file. If it does you will end up with filename.mkv, filename01.txt filename02.txt etc.... or something like that. If you only want to rename mkv files then that should be ok as there probably won't be more than one.
Let us know and I'll try to take a look tonight if you want.