Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2007-03-24
9
Medium Priority
?
4,444 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

 
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 500 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

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…
As much as Microsoft wants to kill off PST file support, just as they tried to do with public folders, there are still times when it is useful or downright necessary to export Exchange mailboxes to PST files. Thankfully, it is still possible to e…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

610 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