Search Results


Thursday, November 26, 2015

How to zip the folder in windows using bat script

It often happens that when you working on ADF and SOA suite using Jdeveloper and something goes wrong and you haven't got a clue what it is. This is mainly because the jdevelopers error reporting is really poor and it doesn't actually say which recent change has caused the XX error in your project.


Unfortunately there is no quick reference that could help resolving the issues. I often rollback to the last checked-in version to fix the issue. If your recent work is not checked in to source control its going to be a nightmare finding the problem.


The work around I have been using, to roll back unchecked-in work, is to zip all the files up using a scheduled windows script, so that I could go back whenever I want or to compare previous files.

Note: If you never used JDeveloper, you will have hard time understanding why we do this.


How to zip the folder in windows using script (No extra Software needed)

  • Create a file zip.vbs with following content

'Get command-line arguments.
Set objArgs = WScript.Arguments
InputFolder = objArgs(0)
ZipFile = objArgs(1)

'Create empty ZIP file.
CreateObject("Scripting.FileSystemObject").CreateTextFile(ZipFile, True).Write "PK" & Chr(5) & Chr(6) & String(18, vbNullChar)

Set objShell = CreateObject("Shell.Application")

Set source = objShell.NameSpace(InputFolder).Items

objShell.NameSpace(ZipFile).CopyHere(source)

'Required!
wScript.Sleep 20000


  • Create archieve.bat script with following content in the same folder

for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set "dt=%%a"
set "DATE=%dt:~0,8%"
set "HOUR=%dt:~8,4%"

set datestamp=%DATE%_%HOUR%
echo datestamp: "%datestamp%"

CScript C:\JDeveloper\mywork\zip.vbs  C:\JDeveloper\mywork\Project12c C:\JDeveloper\mywork\Project12c_%datestamp%.zip



This script will zip the Project12c folder into Project12c_YYYYMMDD_HHMM.zip format. e.g. Project12c_20151126_1000.zip

Now it could be either scheduled in windows or double click the archieve.bat file to zip the project whenever it's needed.

Note 2: If there is a better solution, please leave it on the comments section.

No comments :