Convert ZIP To LHA

Handy for Amiga users who use lots of WHDLOAD files!

Change 'R' to be whatever folder you want to use as a temp folder. My R is a RAMDISK for extra speed and less stress on the HDD or SSD with fragmentation.

Download LHA - Lha for Windows
Download RAMDISK - ImDisk Toolkit download | SourceForge.net

@runmode:hide
COPY EXTRACT CREATEFOLDER r:\lha\{file|noext}
CD r:\lha
"c:\program files (x86)\gnuwin32\bin\lha.exe" -a -i {destpath}\{file|noext}.lha {file|noext}\*.*
DELETE QUIET r:\lha
{sourcepath}

Is the {sourcepath} at the bottom meant to be there on its own?

If you haven't already, it might be worth testing if *.* includes everything with LHA's wildcard handling. It may do, if LHA.exe uses the old MS-DOS conventions. Or it might be like Opus and interpret the wildcard as exactly what it asks for, which would exclude files or folders that don't actually have a . in their names.

Just in case the r:\lha folder already exists and has other files in it that shouldn't be deleted, I'd change the delete line to:

Delete QUITE SKIPNOTEMPTY NORECYCLE r:\lha

That way it'll be left there if there's still something in it.

That's wierd... I put the {sourcepath} there on its own cause without it change to the R folder. Seems to have fixed itself now.

I tried it with without the *.* and it actually makes no difference:
"c:\program files (x86)\gnuwin32\bin\lha.exe" -a -i {destpath}\{file|noext}.lha {file|noext}

The LHA folder is temporary folder, so deleting it shouldn't be a problem. It's created in the COPY line, and since I'm using a RAM disk which is dynamically resized with that program, no point leaving it all in RAM once it's done with it I guess. NORECYCLE is a good idea.

Updated:

@runmode:hide
COPY EXTRACT CREATEFOLDER r:\lha\{file|noext}
CD r:\lha
"c:\program files (x86)\gnuwin32\bin\lha.exe" -a -i {destpath}\{file|noext}.lha {file|noext}
DELETE QUIET NORECYCLE r:\lha
1 Like

On your system, but it might have something important on someone else's. Or you might be running two conversions in parallel, even on your own system.

If the temp folder should be empty at the end then adding SKIPNOTEMPTY shouldn't affect any expected situations but may save you from deleting files that shouldn't be deleted (yet) in unexpected situations.

Here's another version in the MS-DOS Batch Function format which displays the progress in a popup window. The other version can seem like it's not doing anything if there are alot of ZIP files to extract as was in my case. Again R drive refers to RAMDISK so rename it to your favourite temporary drive. This one uses RAMDISK, 7ZIP and LHA.

Download 7Zip - Download
Download LHA - Lha for Windows
Download RAMDISK - ImDisk Toolkit download | SourceForge.net

@echo off
echo --------------------------
echo DOPUS ZIP TO LHA CONVERTER
echo by Paul Pritsis 2021 v1.00
echo --------------------------
echo. 

:_extractZIP
  echo Extracting {filepath$}
  MD R:\LHATEMP
  "C:\PROGRAM FILES (X86)\7-ZIP\7Z.EXE" X {filepath$} -oR:\LHATEMP\{file|noext} -y

:_freezingLHA
  echo.
  echo Freezing files...
  CD R:\LHATEMP
  R:
  "C:\PROGRAM FILES (X86)\GNUWIN32\BIN\LHA.EXE" a {destpath}\{file|noext}.lha {file|noext}

:_end
  echo.
  echo Cleaning Up...
  CD \
  RD /S /Q R:\LHATEMP
  echo.
  echo All Done!
  echo.
  pause