Re: Compressed (zipped) Folder - command line variant?
- From: "Fred" <Fred@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 21 Jun 2005 16:15:04 -0700
I can't get the script to work either.
Here is my session copied from a DOS Window:
---
D:\Vbs> type ZipTest.vbs
Set objShell = CreateObject("Shell.Application")
Set Ag=Wscript.Arguments
set WshShell = WScript.CreateObject("WScript.Shell")
Set DestFldr=objShell.NameSpace(Ag(1))
Set SrcFldr=objShell.NameSpace(Ag(0))
Set FldrItems=SrcFldr.Items
DestFldr.CopyHere FldrItems, &H214
Msgbox "Finished"
D:\Vbs> dir c:\test
Volume in drive C has no label.
Volume Serial Number is A0FD-483A
Directory of c:\test
06/21/2005 17:06 <DIR> .
06/21/2005 17:06 <DIR> ..
06/21/2005 13:44 1,671,168 Track01 (2) .ISO
06/21/2005 13:43 1,671,168 Track01.ISO
06/21/2005 13:45 1,671,168 Track01.zip
3 File(s) 5,013,504 bytes
2 Dir(s) 125,554,696,192 bytes free
D:\Vbs> cscript ZipTest.vbs c:\test c:\test\test.zip
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
D:\Vbs\ZipTest.vbs(8, 1) Microsoft VBScript runtime error:
Object required: 'DestFldr'
D:\Vbs>
---
My intentions are to copy the files in c:\test to the zip file
c:\test\test.zip.
Any ideas?? TIA
"David Candy" wrote:
> You cut and pasted it wrong.
>
> I've been playing with it and when zipping it often doesn't do anything. Poping up a dialog box makes it work. It could be a timing issue. But putting a msgbox at the end of the code always zips.
>
> unzip <folder or zip name to be copied from> <folder or zip name to copy to>
> unZip.vbs" "C:\Documents and Settings\David Candy\Desktop\test" "C:\Documents and
> Settings\David Candy\Desktop\AFDG_W.zip"
>
>
> Set objShell = CreateObject("Shell.Application")
> Set Ag=Wscript.Arguments
> set WshShell = WScript.CreateObject("WScript.Shell")
>
> Set DestFldr=objShell.NameSpace(Ag(1))
> Set SrcFldr=objShell.NameSpace(Ag(0))
> Set FldrItems=SrcFldr.Items
> DestFldr.CopyHere FldrItems, &H214
> Msgbox "Finished"
>
>
>
> --
> --------------------------------------------------------------------------------------------------
> http://webdiary.smh.com.au/archives/_comment/001075.html
> =================================================
> "Tempest261" <Tempest261@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:709EDEB0-9BD7-48BF-8399-40E6AB1A74AF@xxxxxxxxxxxxxxxx
> > David,
> >
> > I tried that script and ran into a few problems. I wanted to first try it in
> > its original format, so I copied and pasted the top portion. I have some
> > programming experience but skipped the whole shell scripting phase, so I just
> > assumed that you needed the private constants and the top part of the
> > program, minus the parts that are obviously not code.
> >
> > The command line didn't like the constants, so I figured those might be
> > built in, and then it accepted most of the script except for the last part-
> > "DestFldr.CopyHere FldrItems, &H214" gave me the error:
> >
> > & H214 ' DestFldr.CopyHere' is not recognized as an internal or external
> > command, operable program or batch file. 'H214' is not recognized as an
> > internal or external command, operable program or batch file.
> >
> > Any ideas?
> >
> > Thanks,
> > Mike
> >
> >
> > "David Candy" wrote:
> >
> >> This script extracts files from a zip passed on the command line and makes a folder on the desktop with the contents. Just do reverse to zip. A new zip file is easly created (look at a new one - it's 14 bytes of mostly null but starting PK). This uses Shell commands rather than File commands. We are working with shell objects that merely happen to be files.
> >>
> >> Set objShell = CreateObject("Shell.Application")
> >> Set Ag=Wscript.Arguments
> >> set WshShell = WScript.CreateObject("WScript.Shell")
> >>
> >>
> >> Set DestFldr=objShell.NameSpace(Ag(1))
> >> Set SrcFldr=objShell.NameSpace(Ag(0))
> >> Set FldrItems=SrcFldr.Items
> >> DestFldr.CopyHere FldrItems, &H214
> >>
> >>
> >> I specified options of 0x214 (&h214) in hex. 200 + 10 + 4, change to suit your purposes.
> >>
> >> Private Const FO_MOVE As Long = &H1
> >> Private Const FO_COPY As Long = &H2
> >> Private Const FO_DELETE As Long = &H3
> >> Private Const FO_RENAME As Long = &H4
> >>
> >> Private Const FOF_MULTIDESTFILES As Long = &H1
> >> Private Const FOF_CONFIRMMOUSE As Long = &H2
> >> Private Const FOF_SILENT As Long = &H4
> >> Private Const FOF_RENAMEONCOLLISION As Long = &H8
> >> Private Const FOF_NOCONFIRMATION As Long = &H10
> >> Private Const FOF_WANTMAPPINGHANDLE As Long = &H20
> >> Private Const FOF_CREATEPROGRESSDLG As Long = &H0
> >> Private Const FOF_ALLOWUNDO As Long = &H40
> >> Private Const FOF_FILESONLY As Long = &H80
> >> Private Const FOF_SIMPLEPROGRESS As Long = &H100
> >> Private Const FOF_NOCONFIRMMKDIR As Long = &H200
> >>
> >> FlagDescription
> >> FOF_ALLOWUNDO Preserve Undo information, if possible. If pFrom does not contain fully qualified path and file names, this flag is ignored.
> >> FOF_CONFIRMMOUSENot currently used.
> >> FOF_FILESONLY Perform the operation on files only if a wildcard file name (*.*) is specified.
> >> FOF_MULTIDESTFILES The pTo member specifies multiple destination files (one for each source file) rather than one directory where all source files are to be deposited.
> >> FOF_NOCONFIRMATION Respond with "Yes to All" for any dialog box that is displayed.
> >> FOF_NOCONFIRMMKDIR Do not confirm the creation of a new directory if the operation requires one to be created.
> >> FOF_NO_CONNECTED_ELEMENTSVersion 5.0. Do not move connected files as a group. Only move the specified files.
> >> FOF_NOCOPYSECURITYATTRIBSVersion 4.71. Do not copy the security attributes of the file.
> >> FOF_NOERRORUI Do not display a user interface if an error occurs.
> >> FOF_NORECURSIONOnly operate in the local directory. Don't operate recursively into subdirectories.
> >> FOF_RECURSEREPARSERecurse into reparse points. The default is to not recurse.
> >> FOF_NORECURSEREPARSETreat reparse points as objects, not containers. You must set _WIN32_WINNT to 5.01 or later to use this flag. See Shell and Common Controls Versions for further discussion of versioning.
> >> FOF_RENAMEONCOLLISION Give the file being operated on a new name in a move, copy, or rename operation if a file with the target name already exists.
> >> FOF_SILENT Do not display a progress dialog box.
> >> FOF_SIMPLEPROGRESS Display a progress dialog box but do not show the file names.
> >> FOF_WANTMAPPINGHANDLE If FOF_RENAMEONCOLLISION is specified and any files were renamed, assign a name mapping object containing their old and new names to the hNameMappings member.
> >> FOF_WANTNUKEWARNINGVersion 5.0. Send a warning if a file is being destroyed during a delete operation rather than recycled. This flag partially overrides FOF_NOCONFIRMATION.
> >>
> >>
> >>
> >>
> >>
> >> --
> >> --------------------------------------------------------------------------------------------------
> >> http://webdiary.smh.com.au/archives/_comment/001075.html
> >> =================================================
> >> "Tempest261" <Tempest261@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:603740A2-288A-4FE5-BCD4-FD1AC82C6298@xxxxxxxxxxxxxxxx
> >> > Is there any way to create a zipped folder from the command line? "Compact"
> >> > doesn't really do what I want (just uses drivespace or something to compress
> >> > the folder).
> >> >
> >> > What I'm trying to do is make a simple batch file that creates a folder,
> >> > throws a bunch of files with the same extenstion into it, and then zips it
> >> > up- but without a command line version of the built-in windows zip program
> >> > this will be impossible (through batch file anyway). Any ideas?
> >>
>
.
- References:
- Compressed (zipped) Folder - command line variant?
- From: Tempest261
- Re: Compressed (zipped) Folder - command line variant?
- From: Tempest261
- Compressed (zipped) Folder - command line variant?
- Prev by Date: Re: Linux O/S on my Windows XPP Home PC
- Next by Date: Closing Control Panel window
- Previous by thread: Re: Compressed (zipped) Folder - command line variant?
- Next by thread: Webshots wallpaper problem
- Index(es):
Relevant Pages
|