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