Batch zip files of same name.

  • Mindz

    Mindz - 2012-06-09

    Hey guys,

    I got one problem.
    I have 6000 files with 1.jpg 1.eps 1.png in one zip with the same name and a.jpg a.eps a.png with with the same name and so on.

    How can I make a script that make this process?

    I found a script but can't run it

    PATH=C:\Program Files\7-Zip
    FOR %F IN (*.JPG) DO 7Z a -tzip "%~nF.ZIP" "%~nF.JPG" "%~nF.EPS" "%~nF.PNG"

    Says that The following usage of the patch operation is batch-in parameter substitution is invalid:  "%~nF.ZIP" "%~nF.JPG" "%~nF.EPS" "%~nF.PNG"

    For valid formats type  CALL/? or FOR/?

  • fernando

    fernando - 2012-06-09

    at a command prompt type FOR/?  and read the Help information (this is what the error message instructs).

    attention to…

    To use the FOR command in a batch program, specify %%variable instead of %variable.
    Variable names are case sensitive, so %i is different from %I.


    In addition, substitution of FOR variable references has been enhanced.
    You can now use the following optional syntax:


    double-up the percent symbols (%%) in the script
    FOR %%F IN (*.JPG) DO 7Z a -tzip "%%~nF.ZIP" "%%~nF.JPG" "%%~nF.EPS" "%%~nF.PNG"

  • Mindz

    Mindz - 2012-06-09

    Thanks for the quick reply!

    One problem when I start the bat file it appears for one second and then disappears I can't type anything?

  • Mindz

    Mindz - 2012-06-09

    no wait It worked just changed the %% and everything works fine!!!



Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks