I have these .rar/zip archives into C:\test
test1.rar
test2.rar
Inside test1.rar I haven't folders, just files while in test2.rar I have also a folder inside
I try to extract every rar/zip archives into relative folders with archive content into C:\test2.
I want to use same name of archives for relative folder name
test1 <-- in this folder there are only files because test1.rar had not folders within
test2 <-- content should extracted preserving structure folder inside archive
Script that I use is this
@echo off
set "SourceFolder=C:\test"
set "TargetFolder=C:\test2"
if not exist "%TargetFolder%" md "%TargetFolder%"
"C:\Program Files (x86)\WinRAR\Rar.exe" x -cfg- -idq -r -y "%SourceFolder%\*.rar" "%TargetFolder%"
del /F /Q /S "%SourceFolder%\*.rar">nul
for /D %%D in ("%SourceFolder%\*") do rd "%%D" 2>nul
but this script works bad
- After extraction this script delete my .rar archives from Source Folder, but I don't want this
- It doesn't create
test1folder before to movetest1.rarcontent insidetest1folder. It simply extract content
THIS is output that I expected
C:\test2
|
|--- test1 [folder]
| |
| |--a.txt
| |--b.txt
|
|--- test2 [folder]
|
|--simple [folder]
| |
| |- c.txt
|
|-d.txt
But I get this bad output
C:\test2
|
|
|--a.txt
|--b.txt
|--simple [folder]
| |
| |- c.txt
|
|-d.txt
Solution is this. Thanks to @Mofi for
-adswitch