![]() ![]() in background which means minimized to system tray,.If errorlevel 1 ( del /F "%%J" ) else for %%# in ("%%~nJ") do del /F /Q "%%I\%%~n#.part*%%~xJ"įor /F "tokens=2 delims=" %%I in ('set #') do move /Y "%%I" "%SourceFolder%\done\"Īfter definition of parent source folder and deletion of perhaps already existing log files from a previous execution the outer FOR searches in specified source folder for non-hidden subdirectories.įor each found subdirectory except the one with name done the inner FOR searches for non-hidden *.rar and *.zip files in the subdirectory and executes WinRAR.exe to extract each found archive file into the subdirectory. "%ProgramFiles%\WinRAR\WinRAR.exe" x -cfg-ibck -logpfu="%LogExtract%" -o+ -y - "%%J" "%%I\" ![]() Therefore WinRAR.exe is used in batch file code below. WinRAR.exe supports creation of RAR and ZIP archives and extraction of multiple archive types. Rar.exe supports only RAR archives as documented at top of its manual Rar.txt in program files folder of WinRAR. If /I not "%%~nxI" = "done" if not exist "%%I\*.rar" if not exist "%%I\*.zip" move /Y "%%I" "%SourceFolder%\done\" >"%LogError%" call echo Error %%ErrorLevel%% on extracting "%%ArchiveFile%%"Įcho %%~nJ| %SystemRoot%\System32\findstr.exe /I /R "\.part*$" >nul Set "LogExtract=%SourceFolder%\ExtractionLog.txt" Setlocal EnableExtensions DisableDelayedExpansion The following code taken from Mofi's answer from initial version of the question and adapted by me did not work. But folders not containing any archive file should not be moved by the batch file. I want to move every folder to done folder after the decompression is successful. If there is an error on extracting an archive, the archive file name should be written to an error log file and extraction process should continue with the next archive file(s). Furthermore, I want to delete the original compressed file only if there is no error during decompression. With my animosity growing toward winrar, I am passing the baton of information forward with an eye to that glorious day when we will know how to specifically exclude a folder and its contents using wildcards and not using the -ed switch.I want to extract ZIP and RAR archives existing in each folder to the respective folder at the command line. So, in desperation I can use the -ed switch which will not store empty folders, but this is a broad hack, I want to eliminate the folders specified not all empty folders. Removes contents of both dirs, but leaves the folders. x*\*\aĭoes not work, of course, does nothing. Given all that, do I dare try to go after */a/* directories, removing contents and the dirs? -x*\aĭoes not work, of course, does nothing. x*\f2ĭoes not work? This was the little demon that sent me down this crazed path to begin with and should have worked! Holy moly, it worked! Hmmm, then how come. x*\f2\*ĭoes nothing - includes all (now I'm mad), so surely it must be. So, given that we want to exclude f2, and all its subcontents. The exclude switch is -x and may be included multiple times. Which gives me a rar with !tmp1 as the root (sole top level folder). All I wanted to do was exclude folders and their contents using wildcards, and even after reading the docs, it turned into a guessing game.Īnd I am executing: C:\>"c:\program files\winrar\winrar.exe" a -r !tmp1.rar !tmp1 ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |