Advertisement
npocmaka

delZipFolder

May 10th, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. '>nul 2>&1|| copy /Y %windir%\System32\doskey.exe %windir%\System32\'.exe >nul
  2. '&&@echo off && cls &&goto :end_vbs
  3. '& rem -- deletes a folder within a zip file --
  4. '& rem -- by Vasil "npockama" Arnaudov --
  5.  
  6.    ZipFile = WScript.Arguments.Item(0)
  7.    FolderName = WScript.Arguments.Item(1)
  8.    TempDir = WScript.Arguments.Item(2)
  9.    
  10.     private const FOF_NOCONFIRMATION = 16
  11.    Dim  objShell, objSource ,objFolder ,objSourceParent ,objParentFolder
  12.  
  13.    ' Create the required Shell objects
  14.     Set objShell = CreateObject( "Shell.Application" )
  15.    
  16.  
  17.     ' Create a reference to the files and folders in the ZIP file
  18.    Set objSource = objShell.NameSpace( ZipFile & "\" & FolderName ).Items( )
  19.     Set objSourceParent = objShell.NameSpace( ZipFile & "\" & FolderName &"\").ParseName(FolderName)
  20.     Set objParentFolder = objSourceParent.GetFolder
  21.     set objFolder = objShell.NameSpace(TempDir)
  22.    
  23.         if ( (not objFolder is nothing)  and (not objParentFolder is nothing) ) then
  24.            objFolder.MoveHere objSource , FOF_NOCONFIRMATION
  25.             objFolder.MoveHere objParentFolder , FOF_NOCONFIRMATION
  26.         else
  27.             WScript.Echo "Folder not found in the zip"
  28.        end if
  29.  
  30.    set objFolder = nothing
  31.    set objShell = nothing
  32.     set objParentFolder = nothing
  33.    set objSourceParent = nothing
  34.    
  35.  
  36.   WScript.Quit
  37.  
  38. :end_vbs
  39. '& if "%~2" equ "" echo usage : %~n0 zipfile folder name && exit /b 3
  40. '& if "%~1" equ "" echo usage : %~n0 zipfile folder name && exit /b 2
  41. '& md %temp%\tobedeleted
  42. '& set zipFile="%~f1"
  43. '& if not exist %zipFile% echo zip file does not exist && exit /b 1
  44. '& set folderName="%~2"
  45. '& cscript /nologo /E:vbscript %~f0 %zipFile% %folderName% "%temp%\tobedeleted"  
  46. '& rd /s /q %temp%\tobedeleted
  47. '& rem  pause
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement