Solved

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

Posted on 2007-03-24
9
4,394 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Cannot access port 443 4 575
Windows 2000 Print Server 2 1,017
Windows 16 342
Cannot Upgrade Microsoft Installer on Windows 2000 29 61
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…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

910 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

22 Experts available now in Live!

Get 1:1 Help Now