I often worried what I might do if I had to restore a backup of a year or more of dated folders from the zip archives. Other than a huge amount of work doing it manually I knew there had to be a way to do it with a batch file. I'm sure there are more elegant ways to do this but for my purpose this works great.
This batch file will unzip Aloha date named zip files, recreate the dated folders and copy the files into them
Thanks to Prof. Timo Salmi, repeat.bat and a bit of trial and error
If your backup is setup like ours to create a zip file ie. 20111221.zip from the dated folders containing all the files from that dated folder... but not the folder... this batch file will recreate those folders and copy the files back into them
It has been tested with archives created with pkzip.exe and with infozip's zip.exe (note if pkzip was the creator then any long filenames will be truncated to an 8.3 naming convention) files created with zip.exe will preserve long filenames
You should put infozip's unzip.exe in a folder on your path (I use the windows\system32 folder)
google infozip to get unzip.exe
Warning!
To be on the safe side do not run this in the aloha folder, create a folder on the same drive and put the zip files in there. After you unzip them you can use windows explorer or your favorite file manager to move (move not copy if you are working with a LOT of data) the folders created back into the aloha folder. It is a good idea to stop the CtlSvr service before copying or moving data and restart it when done.
Make sure you save this as anyname.bat not anyname.bat.txt
------ copy starting at the next line ---------
@echo off
rem This batch performs a command or a set of commands on all the chosen
rem files. Usage: REPEAT [FileName1] [FileName2] [FileName3] ...
if not [%2]==[recurse] goto _begin
rem Substitute below any command you wish to perform on the chosen files
for /f "tokens=1 delims=." %%a in ("%1") do set file=%%a
set file = %1
echo %file%
md %file%
unzip -d %file%\ %1
rem Whatever commands commands you might wish to use on the chosen files
rem SecondCommand %1
rem ThirdCommand %1
rem ...
goto _out
:_begin
echo ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
echo ³ REPEAT.BAT Run command(s) on all the chosen files ³
echo ³ Copyright by Prof. Timo Salmi Fri 8-Oct-2004 ³
echo ³ Email: ts@uwasa.fi WWW: ³
echo ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
echo.
if [%1]==[] goto _help
rem The subroutine calling the batch recursively for all the chosen files
:_loop
if not exist %1 goto _err
for %%f in (%1) do call %0 %%f recurse
shift
if not [%1]==[] goto _loop
goto _out
:_err
echo File(s) %1 not found
goto _out
:_help
echo.
echo Wildcards are allowed in the file names.
echo.
echo modified by Eddie Burks: uses infozip's unzip, unzip each zip file in a folder
echo.
echo each file unzips to a separate folder with same name as each zip file
echo.
echo infozip's unzip.exe should be placed in windows system32 folder
echo.
echo Usage: %0 [FileName1] [FileName2] [FileName3] ...
echo %0 *.zip will process all zip files
echo.
echo The logic of this batch has been lost somewhere in history
:_out
if "%USERNAME%"=="ts" if not "%dosbox%"=="true" if not "%cmdbox%"=="true" pause
-------stop copy on the line above-------------------
I named my batch unzip2folder.bat If you run the bat file in an open cmd window or issue cmd /k unzip2folder it will show you correct usage examples
In my case putting unzip2folder.bat into the folder containing the zip files and issuing the command unzip2folder *.zip processes all the zip files in the folder and creates the dated folders in that same folder
You should test this on a few of your zip files before using it on a large number of files
and as always YMMV
This batch file will unzip Aloha date named zip files, recreate the dated folders and copy the files into them
Thanks to Prof. Timo Salmi, repeat.bat and a bit of trial and error
If your backup is setup like ours to create a zip file ie. 20111221.zip from the dated folders containing all the files from that dated folder... but not the folder... this batch file will recreate those folders and copy the files back into them
It has been tested with archives created with pkzip.exe and with infozip's zip.exe (note if pkzip was the creator then any long filenames will be truncated to an 8.3 naming convention) files created with zip.exe will preserve long filenames
You should put infozip's unzip.exe in a folder on your path (I use the windows\system32 folder)
google infozip to get unzip.exe
Warning!
To be on the safe side do not run this in the aloha folder, create a folder on the same drive and put the zip files in there. After you unzip them you can use windows explorer or your favorite file manager to move (move not copy if you are working with a LOT of data) the folders created back into the aloha folder. It is a good idea to stop the CtlSvr service before copying or moving data and restart it when done.
Make sure you save this as anyname.bat not anyname.bat.txt
------ copy starting at the next line ---------
@echo off
rem This batch performs a command or a set of commands on all the chosen
rem files. Usage: REPEAT [FileName1] [FileName2] [FileName3] ...
if not [%2]==[recurse] goto _begin
rem Substitute below any command you wish to perform on the chosen files
for /f "tokens=1 delims=." %%a in ("%1") do set file=%%a
set file = %1
echo %file%
md %file%
unzip -d %file%\ %1
rem Whatever commands commands you might wish to use on the chosen files
rem SecondCommand %1
rem ThirdCommand %1
rem ...
goto _out
:_begin
echo ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
echo ³ REPEAT.BAT Run command(s) on all the chosen files ³
echo ³ Copyright by Prof. Timo Salmi Fri 8-Oct-2004 ³
echo ³ Email: ts@uwasa.fi WWW: ³
echo ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
echo.
if [%1]==[] goto _help
rem The subroutine calling the batch recursively for all the chosen files
:_loop
if not exist %1 goto _err
for %%f in (%1) do call %0 %%f recurse
shift
if not [%1]==[] goto _loop
goto _out
:_err
echo File(s) %1 not found
goto _out
:_help
echo.
echo Wildcards are allowed in the file names.
echo.
echo modified by Eddie Burks: uses infozip's unzip, unzip each zip file in a folder
echo.
echo each file unzips to a separate folder with same name as each zip file
echo.
echo infozip's unzip.exe should be placed in windows system32 folder
echo.
echo Usage: %0 [FileName1] [FileName2] [FileName3] ...
echo %0 *.zip will process all zip files
echo.
echo The logic of this batch has been lost somewhere in history
:_out
if "%USERNAME%"=="ts" if not "%dosbox%"=="true" if not "%cmdbox%"=="true" pause
-------stop copy on the line above-------------------
I named my batch unzip2folder.bat If you run the bat file in an open cmd window or issue cmd /k unzip2folder it will show you correct usage examples
In my case putting unzip2folder.bat into the folder containing the zip files and issuing the command unzip2folder *.zip processes all the zip files in the folder and creates the dated folders in that same folder
You should test this on a few of your zip files before using it on a large number of files
and as always YMMV