I have many files with the same name in many folders throughout a project on a Windows PC. There are hundreds of thousands of source files in thousands of folders.

They need to be sent out for localization. None of the source code can go with them - only the properties files, so I can't just zip the entire project and send it out.

  • I can't chuck them in a zip file - it requires unique names.

  • I tried using Agent Ransack, which will list all the files in their paths, but sadly 7Zip ignores the paths and complains about the lack of unique names.

What I need is a scripted or automated way to get just certain properties files in their respective folders into a zip archive. Then they can be unzipped right over the existing ones when they come back in one operation, too.

  • 1
    What OS are you on? If windows, the FOR command will help you out. – LPChip Feb 19 '15 at 22:26
  • 1
    "There are hundreds of thousands of source files in thousands of folders" shiver – user236012 Feb 20 '15 at 15:33
  • "My god, it's full of files!" – K7AAY Feb 20 '15 at 17:10
  • As mentioned using this FOR command you can achieve here check this thread sourceforge.net/p/sevenzip/discussion/45797/thread/a7639897 which may get you with some idea. – vembutech Feb 20 '15 at 18:02
7z a -tzip project.zip -ir!DIR1\*.cpp

would go out and grab all files with the .cpp extension in and under DIR1 and put them in an archive named project.zip. Then, add more files with the .abc extension to that archive with

7z u project.zip -ir!DIR1\*.abc

-t specifies the Type of archive (ZIP). The -i and -r switches are combined into -ir which Includes filenames and Recurses subdirectories. Wildcards or filenames with spaces must be quoted, a la "Dir\Program files*" or Dir\"Program files"*


You can also generate a list of filespecs to include, with wildcards, and then put only those files in the archive, with:

7z a -r -tzip archive.zip @listfile.txt


Since you used consistent and unique naming conventions for your source code files, you could exclude files you don't want from the archive at creation time with the -x flag, a la:

7z a -r archive1.zip subdir\ -x!*.src

which will generate an archive excluding files which end in .src

The Help File included with 7-zip which you can access from within the GUI version of the app has much more detail and many more switches.


If it were not so immense, I might instead suggest using 7z from the command line to sweep up everything, then delete the source code from the archive before transmission.

7z a -r archive1.zip subdir\

adds all files and sub-folders in and under folder subdir to archive archive1.zip. The file specifications in the archive will contain subdir\ prefix.

Then use the 7zip File Manager to remove the source code files.

  • There are hundreds of thousands of source files in thousands of folders - manually removing them from the zip is harder than manually fetching each file and creating the folders by hand. – davidjmcclelland Feb 19 '15 at 22:45
  • Thanks for the updated answer. Maybe I can use a matching filter in the command line - there are only two file names I am after contained in the thousands of folders, so that might work. – davidjmcclelland Feb 20 '15 at 2:26
  • 7z a -tzip -r "C:\Users\me\path\UI Team\LANGUAGE_STRINGS\messages.zip" messages_??.properties 7z a -tzip -r "C:\Users\me\path\UI Team\LANGUAGE_STRINGS\jspResources.zip" jspResources_??.properties With these two commands I got only the files I needed that shared a common filename. I did not use the FOR or a loop, 7-Zip did all the dirty work behind the scenes. The best advice was to consult the doc on Sourceforge, but it was a comment not an answer, and your suggestions largely mirror what I found on there. I didn't even remember 7-zip had a command line executor haha. – davidjmcclelland Feb 22 '15 at 23:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.