Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

extract zip file but not in a new folder

Status
Not open for further replies.

elly00

Technical User
Jun 30, 2011
69
IT
hi

I have a folder with a zip file like this:
c:\test\aaa.zip

using the code below I can extract the files but in the same folder .."c:\test\aaa\*.files"

How can I modofy the code in oreder to extract the file in my orignal directory "C:\test" and not in C:\test\aaa\?

Set fso = CreateObject("Scripting.FileSystemObject")

path="c:\FILEXML"
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



thanks
 
>in my orignal directory "C:\test"

Given thqt your code as porsented is NOT looking in c:\test but rather in c:\filexml can you please confoirm that you ahve shown us the correct code that you are having problems with?
 
yes sorry c:\test was only an example

I need to extract files in c:\FILEXML the same direcotry if zip file
 
Can't replicate the issue, or see a problem with your code (apart from a missing Next) . Works as expected here (which is why I queried)

Unless, of course, you have a folder called aaa in your zip file ...
 
Ho
No i don’t have a folder in my zip dile.
Simply the cde extract the files in the same directory but in a new folder named with the same ñame of zip file
 
I understand the issue - but the ONLY way I can replicate it is if the zip folder has a folder in its root with the same name as the zip folder. Otherwise your code runs exactly as you describe you want it to on my dev machine.

Is there any chance you can attach a copy of the zip file to this thread?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top