Wscript to zip files
When it comes to task automation in the windows environment, vbscript is a very good scripting language to use. This post documents some useful functions that I had included in my scripts to deal with zip files and create folders.
Although there is a CreateFolder function provided by the FileSystemObject, there are times when we need to create folders within folders recursively. The CreateFolder function provided by the FileSystemObject does not create parent folders of the folder that you want to create. The following vbscript function will create parent folders if they do not already exist. When you have automated tasks creating folders, you will want to delete them when you no longer need them.
The following vbscript function will do just that. End With. Function IsFile path. Function IsFolder path. Function FSExists path. GetBaseName DriveSpec.
End If. If Not fso. FolderExists tempDir Then. CreateFolder tempDir. If IsFile source Then. Echo "Provided source file does not exist". Echo "Provided source folder does not exist". As always please feel free to reply with questions or comments. Note: I just found out that the Windows shell has a file size limitation of around 2gb.
If your source file is too big you will receive the following error:. Something to consider if you decide to implement this globally. Update: This function hangs with a prompt to overwrite files if the destination files exist when unzipping. You many want to ensure that the directory you unzip to contains no duplicates or simply unzip to a new folder.
Good post. For me, it did not run out of the box, so I had to slightly change it. I am not sure if the command wScript. Sleep 12 sec delay in the original script is required or not, so I kept it.
Note: If you want to debug the VBS script, check out this hint , it describes how to activate the debugger to go through it step by step. Simple script Its convert all dump folder and subfolder files in desktop as backup. Starting windows 10 build , you can use TAR. MSDN link. For example, to create a zip file for a directory named folder XYZ that is in inside folder Reports, you can enter the following in the command prompt.
This is link by Tomas has a well written script to zip contents of a folder. To make it work just copy the script into a batch file and execute it by specifying the folder to be zipped source.
Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Batch file script to zip files Ask Question. Asked 8 years, 1 month ago. Active 1 month ago. Viewed k times. Directory master subDirectory x: file1 file2 Directory y: file 3 file 4 I need to create a windows script, a batch file to run from the master directory and give me two zip files x.
Improve this question. James L. Is directory y in the Master Directory? Add a comment. Active Oldest Votes. Improve this answer. Magoo Magoo Did u try it before or after include that ECHO line? Both ways.
0コメント