Sign in to follow this  
Followers 0
goldenix

compress folders winrar CMD

3 posts in this topic

#1 ·  Posted (edited)

I have 5000+ folders & each contains load of files. I want to compress those folders 1 at the time. If there is any other way to batch do this im open to suggestions. Until then i made a script that does work , but there is 1 little problem. It also creates load of subfolders inside of the archive.

As side note(in case u try to suggest winzip), I would like to rar my archives cuz in case they get corrupted, winrar lets you salvage rest of the uncorrupted data.

Run both samples to see the difference:

This is a working sample & it works like intended But only on a C:

; ##Prepare to run sample
    DirCreate('c:\sampledir57')
    DirCreate('c:\sampledir57\1')
    DirCreate('c:\sampledir57\2')
    FileWriteLine('c:\files_to_include.txt', 'c:\sampledir57')
    ShellExecute('c:\')

;## Compress
    RunWait('"C:\Program Files\WinRAR\WinRAR.exe" a -esh -m5 -mt0 "' & _ ; -m5 max compress / -mt0 1 thread
    'c:\sampledir57.rar' & ' " @"C:\files_to_include.txt" ')

;## Clear After
    FileDelete('c:\files_to_include.txt')
    DirRemove('c:\sampledir57')

This is exact the same sample but the working location is desktop now. now it creates subfolders in archive.

$dir1 = 'C:\Documents and Settings\Administrator\Desktop'
$dir2 = 'C:\Documents and Settings\Administrator\Desktop\sampledir57'
$incl = 'C:\Documents and Settings\Administrator\Desktop\files_to_include.txt'

; ##Prepare to run sample
    DirCreate($dir2)
    DirCreate($dir2 & '\1')
    DirCreate($dir2 & '\2')
    FileWriteLine($incl, $dir2)

;## Compress
    RunWait('"C:\Program Files\WinRAR\WinRAR.exe" a -esh -m5 -mt0 "' & _ ; -m5 max compress / -mt0 1 thread
    $dir1 & '\sampledir57.rar' & ' " @"C:\Documents and Settings\Administrator\Desktop\files_to_include.txt" ')

;## Clear After
    FileDelete($incl)
    DirRemove($dir2)
Edited by goldenix

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites



Thanks! :)


Console Browse: Navigate on the WEB in a textual consoleMultiPing!: Show computer on the lan and/or show the local/remote task, ALL animated!KillaWin: Event executingCryptPage: Crypt your webpage and show only with key

Share this post


Link to post
Share on other sites

If there is any other way to batch do this im open to suggestions.

There's a way to do it without AutoIt. Right click on the folders, go to Add To Archive. Then go to the Files tab and put a check mark in the box: Put each file to separate archive.


#include <ByteMe.au3>

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0