I am looking for a simple batch or vbs script I can edit to complete the following tasks.
i.e
C:\Documents\Shop1_A\file.rar
Inside file.rar there is a file.pdf
I require the script to extracted the file.rar to a drive and rename the extracted file to E:\Shop1_A.pdf
There will only ever be 1 file in the archive (no duplicate or overwrite errors)
do you only have pdf
files? If not, try this:
@ECHO OFF &SETLOCAL
set "SourceFolder=%userprofile%"
set "DestinationFolder=%temp%"
for /d /r "%SourceFolder%" %%a in (*) do for %%b in ("%%~fa\*.rar") do for /f "delims=" %%c in ('rar lb "%%~Fb"') do (
rar e -idq "%%~fb" "%%~c" "%DestinationFolder%"
ren "%DestinationFolder%\%%~c" "%%~na%%~Xc"
)
If you don't own rar
, you can also work with the free unrar
.