#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    1
    Rep Power
    0

    Zipping files individually with unknown file type


    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

    Please help!
    I greatly appreciate it.
    -Jason
  2. #2
  3. No Profile Picture
    Still Learning
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Location
    Montreal, Canada
    Posts
    55
    Rep Power
    39
    As a first thought rename the files without extension to ones with.
    Use .woe for WithOut Extension. Then compress as you would others.
    When you unzip them if you need to, rename them back to no extension versions.
    I looked here at devshed but did not find examples how to do the rename. But there is one at stackoverflow.
    http://stackoverflow.com/questions/1025410/find-and-rename-files-with-no-extention
    Last edited by admiraln; December 20th, 2012 at 09:48 PM. Reason: Add URL

IMN logo majestic logo threadwatch logo seochat tools logo