Solved

batch files to automate "Compressed (Zipped) Folder" tasks

Posted on 2007-03-24
9
4,397 Views
Last Modified: 2009-01-15
I am running Windows XP, and frequently use the feature "send to Compressed (Zipped) Folder" to move big files.

Is there a way to write batch files to automate compressing and extracting these files?

Thanks
0
Comment
Question by:hpsuser
  • 4
  • 3
9 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 18785068
Not "those" files...you can use a vbscript to do that.
For a pure batch file, you'd need to grab the command-line versions of pkzip, and pkunzip...
0
 
LVL 12

Expert Comment

by:RubenvdLinden
ID: 18791390
I really like the command-line version of PowerArchiver (PACL), which can be found at http://www.powerarchiver.com/
It comes with a small manual to help you understand all the different commands and parameters, the exit codes (for batch file errorlevel codes) and some examples.

I hope this helps.
0
 

Author Comment

by:hpsuser
ID: 18796633
So it sounds like I'd have to use a different tool then what we're currently using?
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 67

Expert Comment

by:sirbounty
ID: 18796705
Unless you want to script the process (send to compressed folder) using vbscript...I have some sample code, if you're interested...
0
 

Author Comment

by:hpsuser
ID: 18796950
I've never used vbscript, though if it's easy to implement and all I'd need to do is change the directories or files names I can give it a try...Thanks
0
 
LVL 67

Accepted Solution

by:
sirbounty earned 125 total points
ID: 18804282
This is what I'm using...this will recursively compress the .log files in the strPath folder...there may be some 'bugs' (which will error), since I typed this over (couldn't get my mail working at the office...)

Const SHCONTF_NONFOLDERS=&H40
Dim objFSO:Set objFSO=CreateObject("Scripting.FileSystemObject")
strPath="C:\Testing"

ScanDirectory(objFSO.GetFolder(strPath)

Set objFSO=Nothing
wscript.quit

Sub ScanDirectory(objFolder)
  ScanFiles objFolder
  For Each fld in objFolder.Subfolders
    ScanDirectory fld
  Next
End Sub

Sub ScanFiles(objFolder)
  For each file in objFolder.Files
    Compress(file)
  Next
End Sub

Sub Compress(fil)
  strPath=Left(fil,InstrRev(fil,"\"))
  strFile=Mid(fil,InstrRev(fil,"\")+1)
  strExt=Mid(strFile,InstrRev(strFile,".")+1,3)
  If Lcase(strExt)="log" Then
    strZip=strPath & Replace(strFile,"log","zip")
    set zipFil=objFSO.CreateTextFile(strZip)
    zipFil.WriteLine chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18,0)
    zipFil.Close
    Set oApp=CreateObject("Shell.Application")
    oApp.NameSpace(strZip).CopyHere strPath & strFile
    wscript.sleep 7000 'wait for file to be compressed
    Set oApp=Nothing
    Set zipFil=Nothing
    If objFSO.FileExists(strZip) Then objFSO.DeleteFile (fil) 'deletes file if the zip was created
  End If
End Sub
0
 

Author Comment

by:hpsuser
ID: 18847425
thanks, we've just launched the system that this will involve, when I get a chance I'll come back to this to implement.
0
 

Author Comment

by:hpsuser
ID: 19103212
SirBounty - I forgot about this one, finally got around to trying it and it worked, thanks for your help.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Recreate New ADC 1 275
Need the Best Data Leakage Protection (Cloud Based) 1 358
WMI Uptime Script Reporting Incorrect Number on W2k Server 16 768
no logon server available 8 157
NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
Binary Differential Replication, What it is, how it works and how it differs from standard delta file replication
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question