Winrar command line zip folder

command linewinrarzip

I am trying to use WinRAR command line to zip folder:

"c:\Program Files\WinRAR\WinRAR.exe" a -afzip "e:\output.zip" "e:\foldertozip\"

If the foldertozip contains file, the command line works. But if the folder contain no file but folders where sub folder will contain files, it will appear the error saying No files to add.

How can I solve it?

Best Answer

If the folder contains no files apart from subfolder containing files there is an error

Use the -r recurse subfolders switch.


Examples to compress a folder

rar a -r yourfiles.rar *.txt c:\yourfolder

creates archive yourfiles.rar and compresses all .txt files in c:\yourfolder and all its subfolders

rar a yourfiles 

creates archive yourfiles.rar and compresses all files in the current folder, but doesn’t include subfolders (note lack of extension; WinRAR will use the default extension .rar)

  • a command adds to the archive

  • -r switch recurses subfolders

Source Using the WinRAR Command-line tools in Windows

Related Question