0

In folder1 I have a list of files:

file1.exe
ahahdf.exe
ahdfkqkq.exe

I want to run a script and have it create the following files in folder2:

file1.zip
ahahdf.zip
ahdfkqkq.zip

My attempt:

for %%f in (*.*) do "c:\program files\7-zip\7z.exe" a %%f.zip %%f

This creates file1.exe.zip, ... but I need file1.zip, ... (without the .exe extension).

How can I do this?

Bali C
  • 30,582
  • 35
  • 123
  • 152
  • 1
    You should clarify your text, I can't see any question nor a understandable description – jeb Dec 15 '12 at 15:27

1 Answers1

1

Should be

for %%f in (*.*) do "c:\program files\7-zip\7z.exe" a %%~nf.zip %%f

Note %%~nf - ~n tells command interpreter to pick the filename part without extension.

Also I would enclose parameters into double-quotes ("param") to ensure that filenames that contain spaces are properly handled.

Bali C
  • 30,582
  • 35
  • 123
  • 152
Eugene Mayevski 'Callback
  • 45,135
  • 8
  • 71
  • 121