0

I need to loop over a lot of jar files to delete previous signs and remake the sign for each jar so I make this script for windows, it works well but it stops when a 'Warning' message appears; and I have to click 'close' a lot of times. The warning is because "no file was found to delete".

@echo off
REM iterate over jar files in path
for %%x in (C:\My\Path\to\jar\files\*.jar) do (
echo Jar name: %%~nx
echo -------------------------------------

REM delete previous signatures
"C:\Program Files\WinRAR\WinRAR.exe" d %%x *.RSA *.SF

REM execute sign command
C:\My\Path\To\jarsigner.exe -keystore C:\My\Path\to\mykeystore.jks -storepass myStorepassKey -keypass myKeyspassKey %%x keys_alias

)
tec
  • 999
  • 3
  • 18
  • 40
  • If I remember correctly a command line utility should be part of the WinRar distribution (called rar.exe). This should do it for you. – sb9 May 24 '17 at 08:08
  • Thx for the tip. But I the readme sais only works for rar files, either zip. – tec May 24 '17 at 08:16

3 Answers3

1

You can use -inul option. And the -o+ (force overwrite) or -o- (don't overwrite) options might help as well during extraction.

mistika
  • 2,363
  • 2
  • 21
  • 25
0

Since you are editing a .jar file, which is inherently a zip file, you can avoid using WinRAR.

The zip command provides methods to delete entries in a zip file. also, if you have 7zip installed, which is available in Windows, 7z d archive.jar *.RSA -r might do the trick.

See also: How to delete a file from multiple zip archives using 7-Zip

tdihp
  • 2,329
  • 2
  • 23
  • 40
  • Working with 7zip (I had to install it). It doesn't show warnings. – tec May 24 '17 at 08:27
  • 1
    good that it worked for you, but you could still have done it with rar.exe, let's say that it was the only application you had :) – Gerhard May 24 '17 at 08:29
0

If I do C:\Program Files\WinRAR\rar.exe /?

I get all the commands and switches, which means you should rather use rar to run:

"C:\Program Files\WinRAR\rar" d %%x *.RSA *.SF

Jar files are effectively zipped files.

help output:

<Commands>

  a             Add files to archive
  c             Add archive comment
  ch            Change archive parameters
  cw            Write archive comment to file
  d             Delete files from archive
  e             Extract files without archived paths
  f             Freshen files in archive
  i[par]=<str>  Find string in archives
  k             Lock archive
  l[t[a],b]     List archive contents [technical[all], bare]
  m[f]          Move to archive [files only]
  p             Print file to stdout
  r             Repair archive
  rc            Reconstruct missing volumes
  rn            Rename archived files
  rr[N]         Add data recovery record
  rv[N]         Create recovery volumes
  s[name|-]     Convert archive to or from SFX
  t             Test archive files
  u             Update files in archive
  v[t[a],b]     Verbosely list archive contents [technical[all],bare]
  x             Extract files with full path
Gerhard
  • 22,678
  • 7
  • 27
  • 43
  • Thx for answer. But at least in the version I have ( RAR 5.10), the readme sais only works with rar format. – tec May 24 '17 at 08:29
  • well, rar is pretty much zip file, so it should still work. Never the less, you are sorted now :) – Gerhard May 24 '17 at 08:30