The Notebook Review forums were hosted by TechTarget, who shut down them down on January 31, 2022. This static read-only archive was pulled by NBR forum users between January 20 and January 31, 2022, in an effort to make sure that the valuable technical information that had been posted on the forums is preserved. For current discussions, many NBR forum users moved over to NotebookTalk.net after the shutdown.
Problems? See this thread at archive.org.

    7zip + multiple files at once

    Discussion in 'Windows OS and Software' started by JohnnyFlash, Nov 12, 2009.

  1. JohnnyFlash

    JohnnyFlash Notebook Virtuoso

    Reputations:
    372
    Messages:
    2,489
    Likes Received:
    11
    Trophy Points:
    56
    I'm googling now, but I haven't found an answer so far.

    I have a couple folders with 700+ files in them. I want to compress each file into it's own achive without doing each one by hand. Does anyone know the best way to do this?
     
  2. Nebelwand

    Nebelwand Notebook Consultant

    Reputations:
    119
    Messages:
    213
    Likes Received:
    0
    Trophy Points:
    30
    The command line, 7z.exe, and a for loop can do that in a single line:
    Code:
    for /r "C:\target_directory" %i in (*.*) do "%ProgramFiles%\7-Zip\7z.exe" a -t7z "C:\output_directory\%~ni" "%i"
    Note that this assumes unique filenames minus extensions (i.e. foo.mpg and foo.txt will both end up in foo.7z), if that's not the case you'll probably need to put this in a batch file with some additional magic to check/modify the archive file names.
     
  3. JohnnyFlash

    JohnnyFlash Notebook Virtuoso

    Reputations:
    372
    Messages:
    2,489
    Likes Received:
    11
    Trophy Points:
    56
    Nope, they're all identical file names. Thanks!