2014-11-20 4 views
1

기본적으로 주어진 경로의 모든 .zip 아카이브를 압축 해제하는 온라인 스크립트를 발견했습니다. 조용히 파일을 압축 해제 vbscript

sub UnzipAll(path) 

set folder = fso.GetFolder(path) 

for each file in folder.files 

    if (fso.GetExtensionName(file.path)) = "zip" then 

     set objShell = CreateObject("Shell.Application") 

     objshell.NameSpace(path).CopyHere objshell.NameSpace(file.path).Items 

     file.delete 

    end if 

next 

end sub 

실제로 작동하고 있지만, 문제는 내가 의 압축을 풀 것입니다 "자동으로"은 (자동 압축 해제 할 때 "당신이 원하는처럼 나는, 시스템에서 메시지의 어떤 종류를 원하지 않는 것을 의미한다 su 덮어 쓰기? "등).

나는 구글에 많이 검색 한 난 그냥이처럼 "CopyHere"방법에 대한 몇 가지 플래그를 추가 할 필요가 있음을 발견

objshell.NameSpace(path).CopyHere objshell.NameSpace(file.path).Items, *FLAGHERE* 

그러나 문제는 바로 여기에있다. 플래그는 일반적으로 작동하지만 .zip 화일을 압축 해제 할 때 완전히 무시됩니다.

그래서 해결 방법을 찾았지만 도움이되지 않았습니다.

답변

1

나는 혼자 힘으로 관리했습니다. 기본적으로 시간당 1 개의 파일을 압축 해제하려면 모든 파일을 압축 해제하고 복사하기 전에 이미 존재하는지 확인하고 균등하게 삭제하십시오.

set fso = CreateObject("Scripting.FileSystemObject") 


sub estrai(percorso) 

set cartella = fso.GetFolder(percorso) 

for each file in cartella.files 


    if fso.GetExtensionName(file.path) = "zip" then 


     set objShell = CreateObject("Shell.Application") 

     set destinazione = objShell.NameSpace(percorso) 

     set zip_content = objShell.NameSpace(file.path).Items 

     for i = 0 to zip_content.count-1 

      'msgbox fso.Buildpath(percorso,zip_content.item(i).name)+"."+fso.getExtensionName(zip_content.item(i).path) 

      if (fso.FileExists(fso.Buildpath(percorso,zip_content.item(i).name)+"."+fso.getExtensionName(zip_content.item(i).path))) then 

       'msgbox "il file esiste, ora lo cancello" 
       fso.DeleteFile(fso.Buildpath(percorso,zip_content.item(i).name)+"."+fso.getExtensionName(zip_content.item(i).path)) 

      end if 

      destinazione.copyHere(zip_content.item(i)) 

     next   

     file.Delete 

    end if 

next 

'for each sottocartella in cartella.subfolders 
' call estrai(folder.path) 
'next 

end sub 

call estrai("C:\Documents and Settings\Mattia\Desktop\prova")