3

I'm using a batch script to output filenames with specific attributes to a .txt file, in this case older than 30 days. I'd like to then zip or rar those files that are listed in the .txt file.

How would I go about doing this?

5
  • Can you update your question to clarify what operating system you are using?
    – Mox
    Commented Sep 6, 2013 at 2:25
  • Windows 7 to create the batch, i'd like it to be cross compatible with other Windows editions though. Thanks
    – Matt
    Commented Sep 6, 2013 at 2:30
  • At the moment, I'm outputting full path to txt file, so it looks a little like this;
    – Matt
    Commented Sep 6, 2013 at 2:30
  • C:\folder\file.txt C:\folder\file2.txt and so on..
    – Matt
    Commented Sep 6, 2013 at 2:32
  • Could you possibly edit your question to add the current code that prints in the txt file? That might help us updating it to zip/rar your files... Commented Aug 2, 2018 at 15:57

3 Answers 3

3

According to 7z command line options:

Usage: 7z <command> [<switches>...] <archive_name> [<file_names>...]
       [<@listfiles...>]

Since you've already have the list of files you can just use @ for that file. For example to compress files in filelist.txt into test.zip, use the following command

7z a test.zip @filelist.txt

I've tried that and it worked perfectly

0
1

For RAR, just specify the file list in that place in the command line where you usually specify the list of files, but prefix it with "@" character.

For example, you have a list of files that you need to archive, in the list-of-files.txt, one file

rar a archive-file @list-of-files.txt
1

RAR for MSDOS

ls.txt content :

C:\Users\xpacio\Desktop\001\foo.bin
C:\Users\xpacio\Desktop\002\foo.dat

in desktop exist :

001/foo.bin
001/bar.dat
002/foo.dat
002/bar.bin

Command:

rar a -m5 -ep1 -cu [email protected] result.rar C:\Users\xpacio\Desktop\

the comand, make a rar file named result.rar in the actual path.
the rar contents:

   001/FOO.BIN
   002/FOO.DAT

parameters:

-m5  max level of compression
-ep1 cut the path depth 
-cu  convert to UPPERCASE
[email protected] listo of files to process
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .