![]() /S recurses all subdirectories under the provided source, "C:\".To allow the files to be created, simply re-run the command This way youĬan review the files that will be copied, how many there are, total /L will LIST all the files that will be copied the command won't actually copy anything with this option present.C:\OutputFolder this is the destination into which the files will be copied.C:\ this is the source that is to be searched.A quick overview of what these options are doing: If your PC does not have this command, it is available as part of the Windows 2003 Server Resource Kit here.Ĭhange C:\OutputFolder accordingly to whatever directory you want. Robocopy C:\ C:\OutputFolder *.pdf /S /R:1 /W:1 /NDL /XJD /XD OutputFolder /L This will allow you to have all of the files in that one directory (no subdirectories).Īnother option is Robust Copy (robocopy), which will create a mirrored folder structure of the files it finds into the destination folder: Navigate to your destination folder, then Ctrl+ v. Once it finishes finding everything, press Ctrl+ a, then Ctrl+ c. Type *.pdf into the search field at the top right of an Explorer window. ![]() It is also installed if Internet Explorer 5 (or a later version) is installed.Perhaps the simplest option is to use Windows Search from whichever drive you wish to copy the files from (or from My Computer if you want to find them across all of your drives). Windows Script Host is distributed and installed by default on Windows 98 and later versions of Windows. VBScript has been installed by default in every desktop release of Microsoft Windows since Windows 98.ĬScript.exe is part of Windows Script Host. To make the script fully self-contained it creates an empty ZIP file to get started (one could also create an empty ZIP file and copy it to the target system along with the VBScript script). This COM interface can be used from a VBScript script because such a script can access COM components. How it works: the built-in zip functionality in Windows (Windows XP and later?) is exposed through COM interfaces from the Windows shell, explorer.exe - that is the "Shell.Application" part. ![]() It may work if quotesĪre put around the command line parameters. I haven't tested it for paths and file names containing spaces. ' If this script randomly fails or the ZIP file is not complete, ' Required to let the ZIP command execute ![]() ObjShell.NameSpace(ZipFile).CopyHere(source) Set source = objShell.NameSpace(InputFolder).Items Set objShell = CreateObject("Shell.Application") ZipFile = FS.GetAbsolutePathName(objArgs(1))ĬreateObject("Scripting.FileSystemObject").CreateTextFile(ZipFile, True).Write "PK" & Chr(5) & Chr(6) & String(18, vbNullChar) InputFolder = FS.GetAbsolutePathName(objArgs(0)) Set FS = CreateObject("Scripting.FileSystemObject") Where file zip.vbs contains: ' Get command-line arguments. Named C:\someArchive.zip containing all files in folder C:\test3: CScript zip.vbs C:\test3 C:\someArchive.zip Run this in a command-line window to create a ZIP file It is possible to zip files without installation of any additional software (I have tested it). Attempts to use another extension may result in a script error. bat script is in (as it generates a file there).Īlso, please note that the file extension for the compressed file must be. Write access is also required for the folder the. As this is often not the case for the root of drive C TEMPDIR may have to be changed. Write access is required to the parent of the folder stored in TEMPDIR. Here is an all batch file solution (a variation of my other answer) that will zip a file named c:\ue_english.txt and put it in C:\someArchive.zip: set FILETOZIP=c:\ue_english.txtĮcho Set objArgs = WScript.Arguments > _zipIt.vbsĮcho InputFolder = objArgs(0) > _zipIt.vbsĮcho CreateObject("Scripting.FileSystemObject").CreateTextFile(ZipFile, True).Write "PK" ^& Chr(5) ^& Chr(6) ^& String(18, vbNullChar) > _zipIt.vbsĮcho Set objShell = CreateObject("Shell.Application") > _zipIt.vbsĮcho Set source = objShell.NameSpace(InputFolder).Items > _zipIt.vbsĮcho objShell.NameSpace(ZipFile).CopyHere(source) > _zipIt.vbsĬScript _zipIt.vbs %TEMPDIR% C:\someArchive.zip
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |