Advertisement
npocmaka

InZipDel.bat

May 24th, 2013
70
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-- Save this as .bat
  4. '& rem-- it's a hybrid bat/vbs script
  5. '& rem-- deletes a content inside a folder in an archive
  6. '& rem-- by Vasil "npocmaka" Arnaudov  
  7.  
  8.     ZipFile = WScript.Arguments.Item(0)
  9.     FolderName = WScript.Arguments.Item(1)
  10.     TempDir = WScript.Arguments.Item(2)
  11.      
  12.     private const FOF_NOCONFIRMATION = 16
  13.     Dim  objShell, objSource ,objFolder ,objSourceParent ,objParentFolder
  14.  
  15.     ' Create the required Shell objects
  16.    Set objShell = CreateObject( "Shell.Application" )
  17.    
  18.  
  19.     ' Create a reference to the files and folders in the ZIP file
  20.    Set objSource = objShell.NameSpace( ZipFile & "\" & FolderName ).Items( )
  21.     Set objSourceParent = objShell.NameSpace( ZipFile & "\" & FolderName &"\").ParseName(FolderName)
  22.     Set objParentFolder = objSourceParent.GetFolder
  23.     set objFolder = objShell.NameSpace(TempDir)
  24.    
  25.         if ( (not objFolder is nothing)  and (not objParentFolder is nothing) ) then
  26.             objFolder.MoveHere objSource , FOF_NOCONFIRMATION
  27.             objFolder.MoveHere objParentFolder , FOF_NOCONFIRMATION
  28.              else
  29.             WScript.Echo "Folder not found in the zip"
  30.              end if
  31.  
  32.     set objFolder = nothing
  33.     set objShell = nothing
  34.     set objParentFolder = nothing
  35.     set objSourceParent = nothing
  36.    
  37.  
  38.    WScript.Quit
  39.    
  40. :end_vbs
  41. '& if "%~2" equ "" echo usage : %~n0 zipfile folder name && exit /b 3
  42. '& if "%~1" equ "" echo usage : %~n0 zipfile folder name && exit /b 2
  43. '& md %temp%\tobedeleted
  44. '& set zipFile="%~f1"
  45. '& if not exist %zipFile% echo zip file does not exist && exit /b 1
  46. '& set folderName="%~2"
  47. '& cscript /nologo /E:vbscript %~f0 %zipFile% %folderName% "%temp%\tobedeleted"  
  48. '& rd /s /q %temp%\tobedeleted
  49. '& rem  pause
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement