Menu

create zip from sub folders with wild cards

Chorley
2019-03-28
2019-03-30
  • Chorley

    Chorley - 2019-03-28

    I am new to 7 zip and would like to know if there is there a way to create a zip file to include files from sub folders using wild card characters?
    For example, folder1 contains sub folders sfolder1 and sfolder2 which contain files with prefixed numbered filenames.
    Is it possible to select the files to add to the zip using a search pattern like "1234.txt" ( is a wildcard) to include the files "folder1\sfolder1\A1234.txt" and "folder1\sfolder2\ AB1234.txt" for example without having to select the individual files?

     
    • BillAnt

      BillAnt - 2019-03-30

      Currently there's no way to select multiple arbitrary files and folders which are not visible on the same page in the 7Zip file manager window, you must use the command line method. Well technically you could use the "Flat" view but it's kind of messy. It would be a welcome additional to have a tree like view option to be able to select arbitrary files and folders for archiving. ;)

       

      Last edit: BillAnt 2019-03-30
  • mdadm

    mdadm - 2019-03-28

    Try:
    7z a -r arch_name.7z "folder1\*.txt"
    for txt files, option -r to recurse subdirectories or

    7z a -r arch_name.7z "folder1\*"
    or even
    7z a -r arch_name.7z "folder1\"
    for all files and folders in folder1
    quotation marks: " " - use when name of file or directory (folder) contains spaces.

     

    Last edit: mdadm 2019-03-28
  • Chorley

    Chorley - 2019-03-28

    Thanks mdadm, that's very clear.
    Will the archive file retain the folder/sub-folder details for subsequent extraction into the same folder structure?

     
  • mdadm

    mdadm - 2019-03-28

    Will the archive file retain the folder/sub-folder details for subsequent extraction into the same folder structure?

    Yes, if you extract archive with option:
    7z x archive.7z
    and no, if you extract archive with option:
    7z e archive.7z
    With e option all files will be extracted to one current directory. If there are 2 or more files with same names 7-zip will ask you what to do (overwrite, skip, quit, etc.).

    7-Zip will extract all to current working directory. You may use option -o to extract to specified directory, for example:
    7z x archive.7z -oc:\mydir
    Note no space after option -o. This convention is for all options after "-" in 7-Zip.

     

    Last edit: mdadm 2019-03-28

Log in to post a comment.