Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Batch zip files of same name.

Help
Mindz
2012-06-09
2012-12-07
  • 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 1.zip and a.jpg a.eps a.png with a.zip 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

    @ECHO OFF
    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

    first…
    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.

    and..

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

    second…

    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!!!

    Thanks!!