Solved

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

Posted on 2007-03-24
9
4,390 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
 
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

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…
In this article, I will show you HOW TO: Perform a Physical to Virtual (P2V) Conversion the easy way from a computer backup (image).
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

759 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now