windowscommand-line-interface7ziprar

How to pass list of files to winrar/7z for archiving in cmd


Lets say I've a text file which contains paths to specific files e.g.

myFiles.txt

c:\users\%username%\desktop\file1.pdf
c:\users\%username%\desktop\junk.ppt
c:\users\%username%\desktop\image.jpg
c:\users\%username%\downloads\d1.dwg
d:\someFolder\random.exe
.
.
.
.
f:\folder2\code\myprog.cpp

How can I pass this list to rar.exe or 7z.exe so that it can archive these files e.g.

rar.exe myarchive.rar myFiles.txt
Or
7z.exe myarchive.zip myFiles.txt

Solution

  • You can use

    7z.exe a -i@myFiles.txt myarchive.zip