A simple BAT script to unzip ZIP files in all sub-directories and then delete the ZIP files

In this blog post, I will share a simple script to recursively unzip all ZIP files in sub-directories of a directory, and then delete the ZIP files. Such script is useful for example when managing the submissions of papers at academic conferences. The script is based some code on StackOverflow where I have added the function to delete the ZIP files:

FOR /D /r %%F in ("*") DO (
    pushd %CD%
    cd %%F
        FOR %%X in (*.rar *.zip) DO (
            "C:\Program Files\7-zip\7z.exe" x "%%X"
		   del *.zip
        )
    popd
)

This is for Windows. It assumes that you have 7ZIP installed on your computer and that the path to 7ZIP is correct. Save this script into a text file. Rename it to have the .bat extension. Then, double click on the file to run the script. That is all!


Philippe Fournier-Viger is a distinguished professor working in China and founder of the SPMF open source data mining software.

This entry was posted in Other. Bookmark the permalink.

Leave a Reply

Your email address will not be published.