Search code examples
batch-filezipcompressionrarwinrar

Make a exclusion list + files list using winrar command line


I made this script below to make a backup of some files. It works fine, but i wanted make a list for the files that need be skipped from compressing.

For example:

my list.txt has all the files that will be compressed. But i wanted to make another list for the files that need be skipped, like exclusion_list.txt. Actually i put all files that i want be ignored from compressing into the command line, as shown below -x*\Test1 -x*\Test2. But i really wanted to make a exclusion list for not keep changing the command line everytime i need to exclude a file or folder.

How i can do it?

"%winrar%\winrar.exe" a -x*\Test1 -x*\Test2 -ibck -ep1 -ilog%userprofile%\Desktop\log.log "compressed %date:/=.%.rar" "@list.txt"

Solution

  • From the documentation: the exclusion option -x also supports a list file when it is preceded by @:

    "%winrar%\winrar.exe" a -x@exclusion_list.txt -ibck -ep1 -ilog%userprofile%\Desktop\log.log "compressed %date:/=.%.rar" "@list.txt"
    

    with the file exclusion_list.txt containing:

    *\Test1
    *\Test2
    

    By the way, there is even a console version of WinRAR, called rar.exe, which is a non-GUI version.