I am trying to zip files individually, but the file type is unknown

Posted by Jason Mander on Super User See other posts from Super User or by Jason Mander
Published on 2012-12-20T04:01:39Z Indexed on 2012/12/20 5:05 UTC
Read the original article Hit count: 592

I am trying to zip some files with an unknown file type individually. I am using the following code in a batch script to do that:

@ECHO OFF FOR %%A IN (bestbuy*nat*component.cpi*) DO "C:\Program Files\7-Zip\7z.exe" a -mx9 -m0=lzma2:d256m "%%~nA.7z" "%%A"

The code will compress files individually ONLY if the file has an extension. Unfortunately the files that I have don't have any extension. In the code I am trying to zip files by doing a pattern match, the files are getting compressed into ONE file (which I do not want, I want each file compressed individually).

Why does this code create separate zip files when the files have an extension (for example if I add .txt to the end of the files) and when there is no extension the code creates one zipped file.

Can anyone please help me with the code to compress files with unknown file type so that each file gets compressed individually

Your help would be greatly appreciated. Jason

© Super User or respective owner

Related posts about command-line

Related posts about batch