From: Bernie Lee on 4 Oct 2010 10:25 I am trying to do some functions without the assistance of any external programs. Firstly i am looking for some files on the hard disk and if they are found (selected by date) they are copied to a new folder c:\vbsLogs\yymmdd_TTTT_VBS_Errors.log, this works just fine. I am then trying to zip up using XP compression into a zip file in VBSLogs. The zip file gets created but is empty i have used some code that i found here and tried to adapt it. Although i am missing something, (hence my post) My code for the part that isn't working: Function CompressFolder 'strLogOutputFolder = "C:\VBSLogs" CurrentPath = strLogOutputFolder & "\" 'strLogDateFolder = "yymmdd_tttt_vbs_errors.log" (folder) ZipFile = CurrentPath & strLogDateFolder & ".ZIP" 'File2Add = CurrentPath & strLogDateFolder & "\" Folder2Zip = strTargetFolder & "\" MsgBox Folder2Zip,0,"Folder2Zip..." a = CreateEmptyZip(ZipFile) a = AddFile2Zip (ZipFile, File2Add) a = AddFolder2Zip (ZipFile, Folder2Zip) End Function Function AddFile2Zip (sZipFile, sFile2Add) On Error Resume Next AddFile2Zip = True MsgBox "sZipFile: " & sZipFile & " : sFile2Add: " & sFile2Add Set oApp = createobject("Shell.Application") oApp.NameSpace(sZipFile).CopyHere sFile2Add If Err<>0 Then AddFile2Zip=False End Function Function CreateEmptyZip(sPathName) Dim fso, fp Const ForWriting = 2 CreateEmptyZip = True On Error Resume Next Set fso = CreateObject("Scripting.FileSystemObject") Set fp = fso.OpenTextFile( sPathName, ForWriting, True ) If Err <> 0 Then Set opfs = Nothing CreateEmptyZip=False Exit Function end if fp.Write Chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18, 0) If Err <> 0 Then Set opfs = Nothing CreateEmptyZip=False Exit Function End If fp.Close Set fso = Nothing Err.Clear End Function Function AddFolder2Zip (ZipFile, Folder) AddFolder2Zip=True Set oApp = CreateObject("Shell.Application") Set oFolder = oApp.NameSpace(Folder) If Not oFolder Is Nothing Then MsgBox ZipFile & " : " & Folder oApp.NameSpace(ZipFile).CopyHere oFolder.Items Else MsgBox "Nothing to copy" End If If Err <>0 Then AddFolder2Zip=False End Function I may have missed something i have declared here due to my frustrations. Apologies. > On Sunday, May 11, 2008 11:17 AM Ahmad wrote: > Dear sir, > I've some backed up files from variuous locations stored in a folder c:\data > and i want to back fiels in that folder to a single file c:\data.zip > > i used : > -============ > strComputer = "." > Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") > Set colFolders = objWMIService.ExecQuery _ > ("Select * From Win32_Directory Where Name = 'C:\DBsBackup'") > For Each objFolder in colFolders > errResults = objFolder.Compress > Next > -============ > i just need any kind of scripts to make it in scheduled task > but didn't work, any help ? > > thanks > A. Sabry >> On Sunday, May 11, 2008 11:45 AM Pegasus \(MVP\) wrote: >> "Ahmad" <adsf(a)dsf.c> wrote in message >> news:%2348ago3sIHA.4476(a)TK2MSFTNGP06.phx.gbl... >> >> The Compress method compresses all files in the specified >> folder. It does not "zip" them up. You should also modify your >> code like so: >> ("Select * From Win32_Directory Where Name = 'C:\\DBsBackup'") >> >> Have a look here why one single post, perhaps cross-posted, is >> much better than the multiple posts you made: >> http://www.blakjak.demon.co.uk/mul_crss.htm >>> On Sunday, May 18, 2008 9:05 AM Bob H wrote: >>> Two points - >>> 1 - (Pegasus) last time I looked, compressing a folder in XP (at least) >>> resulted in a zip archive. Windows attempts to hide that (or make it >>> invisible to the user), but if you look closer you should find the same >>> result on your system. I have used this fact on numerous occasions.... >>> also the question was not how to zip - though it almost sounds that way at >>> first. All he wanted to do was schedule the code he has. >>> >>> 2 - (A. Sabry) To schedule you task - just add it to you scheduled tasks >>> in control panel. Use a command line invoking it with cscript and you >>> should be all set. >>> >>> BH >>> >>> "Pegasus (MVP)" <I.can(a)fly.com.oz> wrote in message >>> news:OsUkJ43sIHA.4912(a)TK2MSFTNGP03.phx.gbl... >>>> On Sunday, May 18, 2008 10:43 AM Pegasus \(MVP\) wrote: >>>> "Bob H" <BobH(a)somewhere.com> wrote in message >>>> news:ed1CYfOuIHA.1872(a)TK2MSFTNGP04.phx.gbl... >>>> >>>> Thanks for your feedback. To verify your claim, I tried this >>>> little experiment: >>>> - Create a folder c:\Test. >>>> - Populate it with a few files. >>>> - Launch "My Computer". >>>> - Right-click c:\Test, then click Properties, then Advanced. >>>> - Tick "Compress contents to save disk space", then OK, then Apply. >>>> >>>> The files in this folder are now compressed but there is no .zip file >>>> in sight. Each files is individually visible. The native WinXP compression >>>> method does not use the well-known zip-based compression >>>> facility but its own algorithm that stores each file in a compressed >>>> form. >>>> >>>> The "Compress" method used by the OP does the same thing, >>>> hence there is no .zip file. >>>> >>>> If you can generate a .zip file with the VB Script "Compress" >>>> method then I'd love to see your code. >>>>> On Monday, May 19, 2008 8:31 PM Bob H wrote: >>>>> Pegasus - >>>>> you had me for a second... I was sitting there wondering what went wrong >>>>> and realized the first problem. Let me explain... I normally do this from >>>>> the send-to menu. So, right click your C:\Test folder and scroll to the >>>>> 'Send To' menu and then select 'Compressed (zipped) folder'. That is the >>>>> direct execution of the compress verb. That will generate a zipped folder.. >>>>> but, if you have one of the zip variants installed you may not be able to >>>>> see the Send To option that I am talking about. Again, I have to admit >>>>> you had me stumped for a second. I used to believe the two methods were >>>>> identical... I'll have to think about that one a bit. >>>>> >>>>> Happy compressing... >>>>> BH >>>>> >>>>> "Pegasus (MVP)" <I.can(a)fly.com.oz> wrote in message >>>>> news:eLOYMWPuIHA.4492(a)TK2MSFTNGP02.phx.gbl... >>>>>> On Tuesday, May 20, 2008 12:31 AM Al Dunbar wrote: >>>>>> The way I do it is to right-click on a folder, select New..., and select >>>>>> "Compressed (zipped) folder". Behaves like a folder in windows explorer, but >>>>>> is actually a .zip file. >>>>>> >>>>>> /Al >>>>>>> On Friday, May 23, 2008 4:11 AM Tomy wrote: >>>>>>> First you have to create an empty ZIP file named e.g. Empty.zip. >>>>>>> Then: >>>>>>> >>>>>>> Dim fso, winShell, MyTarget, MySource >>>>>>> Set fso =3D CreateObject("Scripting.FileSystemObject") >>>>>>> MySource =3D "c:\folder_to_zip" >>>>>>> MyTarget =3D "c:\zipped_folder.zip" >>>>>>> fso.CopyFile "Empty.zip", MySource >>>>>>> Set winShell =3D createObject("shell.application") >>>>>>> >>>>>>> winShell.namespace(MyTarget).CopyHere MySource ' <-- This is the >>>>>>> COMMAND >>>>>>> >>>>>>> Set winShell =3D Nothing >>>>>>> Set fso =3D Nothing >>>>>>> >>>>>>> Tomy >>>>>>> >>>>>>> On May 11, 5:17=A0pm, "Ahmad" <a...(a)dsf.c> wrote: >>>>>>> ta >>>>>>> ") >>>>>>>> On Friday, May 23, 2008 4:11 AM Tomy wrote: >>>>>>>> Correction: >>>>>>>> >>>>>>>> Dim fso, winShell, MyTarget, MySource >>>>>>>> Set fso =3D CreateObject("Scripting.FileSystemObject") >>>>>>>> MySource =3D "c:\folder_to_zip" >>>>>>>> MyTarget =3D "c:\zipped_folder.zip" >>>>>>>> fso.CopyFile "Empty.zip", MyTarget >>>>>>>> Set winShell =3D createObject("shell.application") >>>>>>>> >>>>>>>> winShell.namespace(MyTarget).CopyHere MySource ' <-- This is IT >>>>>>>> Set winShell =3D Nothing >>>>>>>> Set fso =3D Nothing >>>>>>>> >>>>>>>> >>>>>>>> On May 21, 9:56=A0am, Tomy <Jan.Tomsa.1...(a)gmail.com> wrote: >>>>>>>> data >>>>>>>> v2") >>>>>>>>> On Wednesday, May 28, 2008 8:49 PM boris.tol wrote: >>>>>>>>> On 11 Mai, 17:17, "Ahmad" <a...(a)dsf.c> wrote: >>>>>>>>> ta >>>>>>>>> ") >>>>>>>>> >>>>>>>>> Drag and Drop the Files you wish to compress over this sample VBScript >>>>>>>>> >>>>>>>>> http://www.scriptbox.at.tt/index.php?search=3DZip%20(compress)%20Files.vbs >>>>>>>>> >>>>>>>>> Make some changes to the Script to perform your task. >>>>>>>>>> On Thursday, June 19, 2008 1:17 PM Dou wrote: >>>>>>>>>> I also need to compress a folder to a file (.zip) on Windows. One shoul be >>>>>>>>>> able to do it with winzip (similar to old pkzip, or compress on UNIX) from >>>>>>>>>> command prompt (need a winzip modual download). A better way would be to use >>>>>>>>>> net send command to do the same thing with "Send to compressed (zipped) >>>>>>>>>> Folder" from command prompt. However, I do not know the syntax. If any one >>>>>>>>>> knows, please share. >>>>>>>>>> >>>>>>>>>> Thanks, Doug >>>>>>>>>> >>>>>>>>>> "Bob H" wrote: >>>>>>>>>>> On Thursday, June 19, 2008 4:15 PM Pegasus \(MVP\) wrote: >>>>>>>>>>> The purchased version of WinZip has a command line >>>>>>>>>>> tool called wzzip.exe that you can use to compress any >>>>>>>>>>> number of files to a common .zip file. >>>>>>>>>>>> On Thursday, June 19, 2008 11:06 PM Tim Williams wrote: >>>>>>>>>>>> Have you looked at this (XP) ? >>>>>>>>>>>> >>>>>>>>>>>> http://www.rondebruin.nl/windowsxpzip.htm >>>>>>>>>>>> >>>>>>>>>>>> Tim >>>>>>>>>>>>> On Friday, June 20, 2008 5:21 PM noon wrote: >>>>>>>>>>>>> Il giorno Thu, 19 Jun 2008 10:17:01 -0700, =?Utf-8?B?RG91Zw==?= >>>>>>>>>>>>> <Doug(a)discussions.microsoft.com> ha scritto: >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> ' CreateEmptyZip (nome dello zip da creare) >>>>>>>>>>>>> ' >>>>>>>>>>>>> ' AddFile2Zip (Nome archivio zip, File da aggiungere) >>>>>>>>>>>>> ' >>>>>>>>>>>>> ' AddFolder2Zip (Nome archivio zip, Cartella da aggiungere all'archivio) >>>>>>>>>>>>> ' >>>>>>>>>>>>> ' Creates a zip archive and adds one or more files. >>>>>>>>>>>>> ' Uses Win XP native support for zip archives as folders. >>>>>>>>>>>>> '************************************************ >>>>>>>>>>>>> ScriptFullName = wscript.scriptfullname >>>>>>>>>>>>> CurrentPath = Left(scriptfullname, InStrRev(ScriptFullName, "\")) >>>>>>>>>>>>> >>>>>>>>>>>>> ZipFile = CurrentPath & "test.zip" >>>>>>>>>>>>> FileDaAggiungere = wscript.scriptfullname >>>>>>>>>>>>> FolderDaZippare = CurrentPath & "temp\" >>>>>>>>>>>>> >>>>>>>>>>>>> 'Crea un file zip vuoto. >>>>>>>>>>>>> a = CreateEmptyZip(ZipFile) >>>>>>>>>>>>> msgbox a 'Deve essere True. >>>>>>>>>>>>> >>>>>>>>>>>>> 'Aggiunge un file all'archivio zip appena creato. >>>>>>>>>>>>> a = AddFile2Zip (ZipFile, FileDaAggiungere) >>>>>>>>>>>>> msgbox a >>>>>>>>>>>>> >>>>>>>>>>>>> 'Aggiunge il contenuto di un folder all'archivio zip. >>>>>>>>>>>>> a= AddFolder2Zip (ZipFile, FolderDaZippare) >>>>>>>>>>>>> msgbox a >>>>>>>>>>>>> >>>>>>>>>>>>> Function AddFile2Zip (sZipFile, sFile2Add) >>>>>>>>>>>>> 'Aggiunge un file all'archivio zip esistente. >>>>>>>>>>>>> 'Attenzione: di default il metodo CopyFile sovrascrive. >>>>>>>>>>>>> 'NameSpace vuole un pathname completo e non solo il nome file. >>>>>>>>>>>>> On Error Resume Next >>>>>>>>>>>>> AddFile2Zip = True >>>>>>>>>>>>> Set oApp = createobject("Shell.Application") >>>>>>>>>>>>> oApp.NameSpace(sZipFile).CopyHere sFile2Add >>>>>>>>>>>>> If Err<>0 Then AddFile2Zip=False >>>>>>>>>>>>> End Function >>>>>>>>>>>>> >>>>>>>>>>>>> Function CreateEmptyZip(sPathName) >>>>>>>>>>>>> 'Create empty Zip File. >>>>>>>>>>>>> 'Crea un file zip vuoto. >>>>>>>>>>>>> Dim fso, fp >>>>>>>>>>>>> Const ForWriting = 2 'Apre un file in scrittura. >>>>>>>>>>>>> CreateEmptyZip = True 'se tutto va bene resta true. >>>>>>>>>>>>> On Error Resume Next >>>>>>>>>>>>> Set fso = CreateObject("Scripting.FileSystemObject") >>>>>>>>>>>>> Set fp = fso.OpenTextFile( sPathName, ForWriting, True ) >>>>>>>>>>>>> If Err <> 0 Then >>>>>>>>>>>>> Set opfs = Nothing >>>>>>>>>>>>> CreateEmptyZip=False >>>>>>>>>>>>> Exit Function 'Errore nella creazione >>>>>>>>>>>>> end if >>>>>>>>>>>>> fp.Write Chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18, 0) >>>>>>>>>>>>> If Err <> 0 Then >>>>>>>>>>>>> Set opfs = Nothing >>>>>>>>>>>>> CreateEmptyZip=False >>>>>>>>>>>>> Exit Function 'errore nella scrittura >>>>>>>>>>>>> End If >>>>>>>>>>>>> fp.Close 'Chiude il file, altrimenti non si pu? usare. >>>>>>>>>>>>> Set fso = Nothing >>>>>>>>>>>>> Err.Clear >>>>>>>>>>>>> End Function >>>>>>>>>>>>> >>>>>>>>>>>>> Function AddFolder2Zip (ZipFile, Folder) >>>>>>>>>>>>> 'Copia il contenuto di una cartella in un file zip. >>>>>>>>>>>>> 'Il folder deve essere indicato con pathname completo >>>>>>>>>>>>> 'e terminare con un "\" >>>>>>>>>>>>> 'Zipfile deve essere indicato con pathname completo. >>>>>>>>>>>>> AddFolder2Zip=True >>>>>>>>>>>>> Set oApp = CreateObject("Shell.Application") >>>>>>>>>>>>> 'Copia il contenuto della cartella nello zip. >>>>>>>>>>>>> Set oFolder = oApp.NameSpace(Folder) >>>>>>>>>>>>> If Not oFolder Is Nothing Then >>>>>>>>>>>>> oApp.NameSpace(ZipFile).CopyHere oFolder.Items >>>>>>>>>>>>> End If >>>>>>>>>>>>> If Err <>0 Then AddFolder2Zip=False >>>>>>>>>>>>> End Function >>>>>>>>>>>>> -- >>>>>>>>>>>>> Giovanni Cenati (Bergamo, Italy) >>>>>>>>>>>>> Write to "Reventlov" at katamail com >>>>>>>>>>>>> http://digilander.libero.it/Cenati (Esempi e programmi in VbScript) >>>>>>>>>>>>> -- >>>>>>>>>>>>> Submitted via EggHeadCafe - Software Developer Portal of Choice >>>>>>>>>>>>> Nested IF Statement ? Excel 2007 >>>>>>>>>>>>> http://www.eggheadcafe.com/tutorials/aspnet/195df521-46a8-4b2f-a6aa-dad1fb2c63d5/nested-if-statement--excel-2007.aspx
From: Reventlov on 4 Oct 2010 13:01 Il giorno Mon, 04 Oct 2010 14:25:06 GMT, Bernie Lee <bernie.lee(a)vsii.co.uk> ha scritto: >I am trying to do some functions without the assistance of any external programs. Firstly i am looking for some files on the hard disk and if they are found (selected by date) they are copied to a new folder c:\vbsLogs\yymmdd_TTTT_VBS_Errors.log, this works just fine. I am then trying to zip up using XP compression into a zip file in VBSLogs. The zip file gets created but is empty i have used some code that i found here and tried to adapt it. Although i am missing something, (hence my post) > >My code for the part that isn't working: The compression is actually done in a temp file and then copied in the original zip file. If the script ends before the compression is done, the compression is aborted You have to wait until the zip file actually grows. See the code added below. > >Function CompressFolder >'strLogOutputFolder = "C:\VBSLogs" >CurrentPath = strLogOutputFolder & "\" > >'strLogDateFolder = "yymmdd_tttt_vbs_errors.log" (folder) >ZipFile = CurrentPath & strLogDateFolder & ".ZIP" >'File2Add = CurrentPath & strLogDateFolder & "\" >Folder2Zip = strTargetFolder & "\" >MsgBox Folder2Zip,0,"Folder2Zip..." >a = CreateEmptyZip(ZipFile) >a = AddFile2Zip (ZipFile, File2Add) >a = AddFolder2Zip (ZipFile, Folder2Zip) set fso=createobject("scripting.filesystemobject") Set h=fso.getFile(ZipFile) do wscript.sleep 300 loop while h.size=< 22 >End Function > >Function AddFile2Zip (sZipFile, sFile2Add) >On Error Resume Next >AddFile2Zip = True >MsgBox "sZipFile: " & sZipFile & " : sFile2Add: " & sFile2Add >Set oApp = createobject("Shell.Application") >oApp.NameSpace(sZipFile).CopyHere sFile2Add >If Err<>0 Then AddFile2Zip=False >End Function > >Function CreateEmptyZip(sPathName) >Dim fso, fp >Const ForWriting = 2 >CreateEmptyZip = True >On Error Resume Next >Set fso = CreateObject("Scripting.FileSystemObject") >Set fp = fso.OpenTextFile( sPathName, ForWriting, True ) >If Err <> 0 Then >Set opfs = Nothing >CreateEmptyZip=False >Exit Function >end if >fp.Write Chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18, 0) >If Err <> 0 Then >Set opfs = Nothing >CreateEmptyZip=False >Exit Function >End If >fp.Close >Set fso = Nothing >Err.Clear >End Function > >Function AddFolder2Zip (ZipFile, Folder) > AddFolder2Zip=True > Set oApp = CreateObject("Shell.Application") > Set oFolder = oApp.NameSpace(Folder) > > If Not oFolder Is Nothing Then > MsgBox ZipFile & " : " & Folder > oApp.NameSpace(ZipFile).CopyHere oFolder.Items > Else > MsgBox "Nothing to copy" > End If > > If Err <>0 Then AddFolder2Zip=False > >End Function > >I may have missed something i have declared here due to my frustrations. Apologies. > >> On Sunday, May 11, 2008 11:17 AM Ahmad wrote: > >> Dear sir, >> I've some backed up files from variuous locations stored in a folder c:\data >> and i want to back fiels in that folder to a single file c:\data.zip >> >> i used : >> -============ >> strComputer = "." >> Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") >> Set colFolders = objWMIService.ExecQuery _ >> ("Select * From Win32_Directory Where Name = 'C:\DBsBackup'") >> For Each objFolder in colFolders >> errResults = objFolder.Compress >> Next >> -============ >> i just need any kind of scripts to make it in scheduled task >> but didn't work, any help ? >> >> thanks >> A. Sabry > > >>> On Sunday, May 11, 2008 11:45 AM Pegasus \(MVP\) wrote: > >>> "Ahmad" <adsf(a)dsf.c> wrote in message >>> news:%2348ago3sIHA.4476(a)TK2MSFTNGP06.phx.gbl... >>> >>> The Compress method compresses all files in the specified >>> folder. It does not "zip" them up. You should also modify your >>> code like so: >>> ("Select * From Win32_Directory Where Name = 'C:\\DBsBackup'") >>> >>> Have a look here why one single post, perhaps cross-posted, is >>> much better than the multiple posts you made: >>> http://www.blakjak.demon.co.uk/mul_crss.htm > > >>>> On Sunday, May 18, 2008 9:05 AM Bob H wrote: > >>>> Two points - >>>> 1 - (Pegasus) last time I looked, compressing a folder in XP (at least) >>>> resulted in a zip archive. Windows attempts to hide that (or make it >>>> invisible to the user), but if you look closer you should find the same >>>> result on your system. I have used this fact on numerous occasions.... >>>> also the question was not how to zip - though it almost sounds that way at >>>> first. All he wanted to do was schedule the code he has. >>>> >>>> 2 - (A. Sabry) To schedule you task - just add it to you scheduled tasks >>>> in control panel. Use a command line invoking it with cscript and you >>>> should be all set. >>>> >>>> BH >>>> >>>> "Pegasus (MVP)" <I.can(a)fly.com.oz> wrote in message >>>> news:OsUkJ43sIHA.4912(a)TK2MSFTNGP03.phx.gbl... > > >>>>> On Sunday, May 18, 2008 10:43 AM Pegasus \(MVP\) wrote: > >>>>> "Bob H" <BobH(a)somewhere.com> wrote in message >>>>> news:ed1CYfOuIHA.1872(a)TK2MSFTNGP04.phx.gbl... >>>>> >>>>> Thanks for your feedback. To verify your claim, I tried this >>>>> little experiment: >>>>> - Create a folder c:\Test. >>>>> - Populate it with a few files. >>>>> - Launch "My Computer". >>>>> - Right-click c:\Test, then click Properties, then Advanced. >>>>> - Tick "Compress contents to save disk space", then OK, then Apply. >>>>> >>>>> The files in this folder are now compressed but there is no .zip file >>>>> in sight. Each files is individually visible. The native WinXP compression >>>>> method does not use the well-known zip-based compression >>>>> facility but its own algorithm that stores each file in a compressed >>>>> form. >>>>> >>>>> The "Compress" method used by the OP does the same thing, >>>>> hence there is no .zip file. >>>>> >>>>> If you can generate a .zip file with the VB Script "Compress" >>>>> method then I'd love to see your code. > > >>>>>> On Monday, May 19, 2008 8:31 PM Bob H wrote: > >>>>>> Pegasus - >>>>>> you had me for a second... I was sitting there wondering what went wrong >>>>>> and realized the first problem. Let me explain... I normally do this from >>>>>> the send-to menu. So, right click your C:\Test folder and scroll to the >>>>>> 'Send To' menu and then select 'Compressed (zipped) folder'. That is the >>>>>> direct execution of the compress verb. That will generate a zipped folder.. >>>>>> but, if you have one of the zip variants installed you may not be able to >>>>>> see the Send To option that I am talking about. Again, I have to admit >>>>>> you had me stumped for a second. I used to believe the two methods were >>>>>> identical... I'll have to think about that one a bit. >>>>>> >>>>>> Happy compressing... >>>>>> BH >>>>>> >>>>>> "Pegasus (MVP)" <I.can(a)fly.com.oz> wrote in message >>>>>> news:eLOYMWPuIHA.4492(a)TK2MSFTNGP02.phx.gbl... > > >>>>>>> On Tuesday, May 20, 2008 12:31 AM Al Dunbar wrote: > >>>>>>> The way I do it is to right-click on a folder, select New..., and select >>>>>>> "Compressed (zipped) folder". Behaves like a folder in windows explorer, but >>>>>>> is actually a .zip file. >>>>>>> >>>>>>> /Al > > >>>>>>>> On Friday, May 23, 2008 4:11 AM Tomy wrote: > >>>>>>>> First you have to create an empty ZIP file named e.g. Empty.zip. >>>>>>>> Then: >>>>>>>> >>>>>>>> Dim fso, winShell, MyTarget, MySource >>>>>>>> Set fso =3D CreateObject("Scripting.FileSystemObject") >>>>>>>> MySource =3D "c:\folder_to_zip" >>>>>>>> MyTarget =3D "c:\zipped_folder.zip" >>>>>>>> fso.CopyFile "Empty.zip", MySource >>>>>>>> Set winShell =3D createObject("shell.application") >>>>>>>> >>>>>>>> winShell.namespace(MyTarget).CopyHere MySource ' <-- This is the >>>>>>>> COMMAND >>>>>>>> >>>>>>>> Set winShell =3D Nothing >>>>>>>> Set fso =3D Nothing >>>>>>>> >>>>>>>> Tomy >>>>>>>> >>>>>>>> On May 11, 5:17=A0pm, "Ahmad" <a...(a)dsf.c> wrote: >>>>>>>> ta >>>>>>>> ") > > >>>>>>>>> On Friday, May 23, 2008 4:11 AM Tomy wrote: > >>>>>>>>> Correction: >>>>>>>>> >>>>>>>>> Dim fso, winShell, MyTarget, MySource >>>>>>>>> Set fso =3D CreateObject("Scripting.FileSystemObject") >>>>>>>>> MySource =3D "c:\folder_to_zip" >>>>>>>>> MyTarget =3D "c:\zipped_folder.zip" >>>>>>>>> fso.CopyFile "Empty.zip", MyTarget >>>>>>>>> Set winShell =3D createObject("shell.application") >>>>>>>>> >>>>>>>>> winShell.namespace(MyTarget).CopyHere MySource ' <-- This is IT >>>>>>>>> Set winShell =3D Nothing >>>>>>>>> Set fso =3D Nothing >>>>>>>>> >>>>>>>>> >>>>>>>>> On May 21, 9:56=A0am, Tomy <Jan.Tomsa.1...(a)gmail.com> wrote: >>>>>>>>> data >>>>>>>>> v2") > > >>>>>>>>>> On Wednesday, May 28, 2008 8:49 PM boris.tol wrote: > >>>>>>>>>> On 11 Mai, 17:17, "Ahmad" <a...(a)dsf.c> wrote: >>>>>>>>>> ta >>>>>>>>>> ") >>>>>>>>>> >>>>>>>>>> Drag and Drop the Files you wish to compress over this sample VBScript >>>>>>>>>> >>>>>>>>>> http://www.scriptbox.at.tt/index.php?search=3DZip%20(compress)%20Files.vbs >>>>>>>>>> >>>>>>>>>> Make some changes to the Script to perform your task. > > >>>>>>>>>>> On Thursday, June 19, 2008 1:17 PM Dou wrote: > >>>>>>>>>>> I also need to compress a folder to a file (.zip) on Windows. One shoul be >>>>>>>>>>> able to do it with winzip (similar to old pkzip, or compress on UNIX) from >>>>>>>>>>> command prompt (need a winzip modual download). A better way would be to use >>>>>>>>>>> net send command to do the same thing with "Send to compressed (zipped) >>>>>>>>>>> Folder" from command prompt. However, I do not know the syntax. If any one >>>>>>>>>>> knows, please share. >>>>>>>>>>> >>>>>>>>>>> Thanks, Doug >>>>>>>>>>> >>>>>>>>>>> "Bob H" wrote: > > >>>>>>>>>>>> On Thursday, June 19, 2008 4:15 PM Pegasus \(MVP\) wrote: > >>>>>>>>>>>> The purchased version of WinZip has a command line >>>>>>>>>>>> tool called wzzip.exe that you can use to compress any >>>>>>>>>>>> number of files to a common .zip file. > > >>>>>>>>>>>>> On Thursday, June 19, 2008 11:06 PM Tim Williams wrote: > >>>>>>>>>>>>> Have you looked at this (XP) ? >>>>>>>>>>>>> >>>>>>>>>>>>> http://www.rondebruin.nl/windowsxpzip.htm >>>>>>>>>>>>> >>>>>>>>>>>>> Tim > > >>>>>>>>>>>>>> On Friday, June 20, 2008 5:21 PM noon wrote: > >>>>>>>>>>>>>> Il giorno Thu, 19 Jun 2008 10:17:01 -0700, =?Utf-8?B?RG91Zw==?= >>>>>>>>>>>>>> <Doug(a)discussions.microsoft.com> ha scritto: >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> ' CreateEmptyZip (nome dello zip da creare) >>>>>>>>>>>>>> ' >>>>>>>>>>>>>> ' AddFile2Zip (Nome archivio zip, File da aggiungere) >>>>>>>>>>>>>> ' >>>>>>>>>>>>>> ' AddFolder2Zip (Nome archivio zip, Cartella da aggiungere all'archivio) >>>>>>>>>>>>>> ' >>>>>>>>>>>>>> ' Creates a zip archive and adds one or more files. >>>>>>>>>>>>>> ' Uses Win XP native support for zip archives as folders. >>>>>>>>>>>>>> '************************************************ >>>>>>>>>>>>>> ScriptFullName = wscript.scriptfullname >>>>>>>>>>>>>> CurrentPath = Left(scriptfullname, InStrRev(ScriptFullName, "\")) >>>>>>>>>>>>>> >>>>>>>>>>>>>> ZipFile = CurrentPath & "test.zip" >>>>>>>>>>>>>> FileDaAggiungere = wscript.scriptfullname >>>>>>>>>>>>>> FolderDaZippare = CurrentPath & "temp\" >>>>>>>>>>>>>> >>>>>>>>>>>>>> 'Crea un file zip vuoto. >>>>>>>>>>>>>> a = CreateEmptyZip(ZipFile) >>>>>>>>>>>>>> msgbox a 'Deve essere True. >>>>>>>>>>>>>> >>>>>>>>>>>>>> 'Aggiunge un file all'archivio zip appena creato. >>>>>>>>>>>>>> a = AddFile2Zip (ZipFile, FileDaAggiungere) >>>>>>>>>>>>>> msgbox a >>>>>>>>>>>>>> >>>>>>>>>>>>>> 'Aggiunge il contenuto di un folder all'archivio zip. >>>>>>>>>>>>>> a= AddFolder2Zip (ZipFile, FolderDaZippare) >>>>>>>>>>>>>> msgbox a >>>>>>>>>>>>>> >>>>>>>>>>>>>> Function AddFile2Zip (sZipFile, sFile2Add) >>>>>>>>>>>>>> 'Aggiunge un file all'archivio zip esistente. >>>>>>>>>>>>>> 'Attenzione: di default il metodo CopyFile sovrascrive. >>>>>>>>>>>>>> 'NameSpace vuole un pathname completo e non solo il nome file. >>>>>>>>>>>>>> On Error Resume Next >>>>>>>>>>>>>> AddFile2Zip = True >>>>>>>>>>>>>> Set oApp = createobject("Shell.Application") >>>>>>>>>>>>>> oApp.NameSpace(sZipFile).CopyHere sFile2Add >>>>>>>>>>>>>> If Err<>0 Then AddFile2Zip=False >>>>>>>>>>>>>> End Function >>>>>>>>>>>>>> >>>>>>>>>>>>>> Function CreateEmptyZip(sPathName) >>>>>>>>>>>>>> 'Create empty Zip File. >>>>>>>>>>>>>> 'Crea un file zip vuoto. >>>>>>>>>>>>>> Dim fso, fp >>>>>>>>>>>>>> Const ForWriting = 2 'Apre un file in scrittura. >>>>>>>>>>>>>> CreateEmptyZip = True 'se tutto va bene resta true. >>>>>>>>>>>>>> On Error Resume Next >>>>>>>>>>>>>> Set fso = CreateObject("Scripting.FileSystemObject") >>>>>>>>>>>>>> Set fp = fso.OpenTextFile( sPathName, ForWriting, True ) >>>>>>>>>>>>>> If Err <> 0 Then >>>>>>>>>>>>>> Set opfs = Nothing >>>>>>>>>>>>>> CreateEmptyZip=False >>>>>>>>>>>>>> Exit Function 'Errore nella creazione >>>>>>>>>>>>>> end if >>>>>>>>>>>>>> fp.Write Chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18, 0) >>>>>>>>>>>>>> If Err <> 0 Then >>>>>>>>>>>>>> Set opfs = Nothing >>>>>>>>>>>>>> CreateEmptyZip=False >>>>>>>>>>>>>> Exit Function 'errore nella scrittura >>>>>>>>>>>>>> End If >>>>>>>>>>>>>> fp.Close 'Chiude il file, altrimenti non si pu? usare. >>>>>>>>>>>>>> Set fso = Nothing >>>>>>>>>>>>>> Err.Clear >>>>>>>>>>>>>> End Function >>>>>>>>>>>>>> >>>>>>>>>>>>>> Function AddFolder2Zip (ZipFile, Folder) >>>>>>>>>>>>>> 'Copia il contenuto di una cartella in un file zip. >>>>>>>>>>>>>> 'Il folder deve essere indicato con pathname completo >>>>>>>>>>>>>> 'e terminare con un "\" >>>>>>>>>>>>>> 'Zipfile deve essere indicato con pathname completo. >>>>>>>>>>>>>> AddFolder2Zip=True >>>>>>>>>>>>>> Set oApp = CreateObject("Shell.Application") >>>>>>>>>>>>>> 'Copia il contenuto della cartella nello zip. >>>>>>>>>>>>>> Set oFolder = oApp.NameSpace(Folder) >>>>>>>>>>>>>> If Not oFolder Is Nothing Then >>>>>>>>>>>>>> oApp.NameSpace(ZipFile).CopyHere oFolder.Items >>>>>>>>>>>>>> End If >>>>>>>>>>>>>> If Err <>0 Then AddFolder2Zip=False >>>>>>>>>>>>>> End Function >>>>>>>>>>>>>> -- >>>>>>>>>>>>>> Giovanni Cenati (Bergamo, Italy) >>>>>>>>>>>>>> Write to "Reventlov" at katamail com >>>>>>>>>>>>>> http://digilander.libero.it/Cenati (Esempi e programmi in VbScript) >>>>>>>>>>>>>> -- > > >>>>>>>>>>>>>> Submitted via EggHeadCafe - Software Developer Portal of Choice >>>>>>>>>>>>>> Nested IF Statement ? Excel 2007 >>>>>>>>>>>>>> http://www.eggheadcafe.com/tutorials/aspnet/195df521-46a8-4b2f-a6aa-dad1fb2c63d5/nested-if-statement--excel-2007.aspx -- Giovanni Cenati (Bergamo, Italy) Write to "Reventlov" at katamail com http://digilander.libero.it/Cenati (Esempi e programmi in VbScript) --
|
Pages: 1 Prev: Article Discussion: ASP.NET Caching Concepts Next: how can i duplicate characters |