Xona.com: the spyware-free web presence of Matthew Doucette & Jason Doucette.
Home
Contact
About
Forums
 ___
Games:
Duality: ZF
 ___
Articles:
Tech
Windows
Webmaster
Blog
Coding
 ___
Web Utilities:
Domain Hacks
Suggest
 ___
Freeware:
ZoomView
AntiSpam Mailto
 ___
Quotes:
Inspirational
Intelligence
Education
Action
Scientific
Chess
Financial
Programming
 ___
Social Networks:
YouTube
Facebook
 ___
Books
Videos
Wallpapers
 ___
Music
Color List
TI-99/4A
Parsec
Optical Illusions
Web Design
Trivia
Domains
Donations
Copyrights
Disclaimer
Links
 ___
Forums
About
Contact
WinRAR Tip #3: Delete Multiple Files out of Multiple RAR Files


Wednesday, July 05, 2006
By: Matthew Doucette
Printer Friendly Version

WinRAR is a file compressor / archiver great for backing up data.  Download WinRAR at rarlab.com/download.htm.

 

WinRAR Tip #3: Delete Multiple Files out of Multiple RAR Files:

Use one of these convenient batch files:

Windows version WinRAR batch file:

REM Windows Version
for %%I in (*.rar) do "C:\Program Files\WinRAR\WinRAR.exe" d -ibck -pYOURPASSWORD "%%I" *.exe *.txt *.rar
pause

Command line version WinRAR batch file:

REM Command Line Version
for %%I in (*.rar) do "C:\Program Files\WinRAR\RAR.exe" d -ibck -pYOURPASSWORD "%%I" *.exe *.txt *.rar
pause

They delete all *.exe, *.txt, and *.rar files out of every RAR file in the same folder as the batch file, including those password protected with "YOURPASSWORD" as the password.  (Security tip:  Do not use "YOURPASSWORD" as your password!  Visit GRC's Ultra High Security Password Generator for tips on secure password generation.)

This batch file is only an example.  You must modify it to specifically suit your needs.

To create the batch file, copy the above quoted text into Notepad and save it as "delete.bat", (without quotes).  delete.bat will be your batch file.  Put delete.bat in the same folder as the RAR files.  (Always make backups before messing with your data.  I recommend doing testing in a folder away from your actual data using copies of your actual data.)

Batch file warning:  Double-clicking a batch file (.bat file) executes the batch file's commands, it does not open it for editing!  To open a batch file, you must right-click it and choose "edit".

The example batch file above will delete all *.exe, *.txt, and *.rar files from all RAR files found in the current folder that are password protected via the password "YOURPASSWORD".

Let me break down the batch file for you

  • REM stand for "remarks" and is how you provide commenting.  Anything after "REM" is ignore during execution.  In the examples above, I labeled the windows and command line versions using the REM command.
  • for %%I in (*.rar) do is the batch file loop.  It sets %%I to 'be' each RAR file in the current folder.
  • "%%I", with one set of quotes, is the loop variable that 'becomes' each RAR file.
  • "C:\Program Files\WinRAR\WinRAR.exe" d -ibck -pYOURPASSWORD "%%I" *.exe *.txt *.rar (from the Windows batch file version) is the full command that is run for each iteration of the loop, with "%%I" 'becoming' each RAR file in the current folder.  This is similar for the command line version minus the path to the programs, explained next:
  • "C:\Program Files\WinRAR\WinRAR.exe" is the full path to the Windows version of WinRAR.  Change this if you have installed it in a different location.
  • "C:\Program Files\WinRAR\RAR.exe" is the full path to the command line version of WinRAR.  Change this if you have installed it in a different location.
  • d is a WinRAR command line switch that signifies you wish to delete files from a RAR archive.
  • -ibck is a WinRAR command line switch that signifies you wish WinRAR to run as a background process.  This helps you continue to use your computer while WinRAR is working, as it makes WinRAR run under a low priority.
  •  -pYOURPASSWORD is a WinRAR command line switch that signifies the password you wish to use for archives that are password protected.  Replace YOURPASSWORD with your actual password.  If you do not use this command line switch and WinRAR runs into a password protected archive, it will ask you for it manually.  This is only a problem if you have so many RAR files to process that you do not wish to wait to type in a password for each one.
  • "%%I", already explained, is the loop variable that 'becomes' each RAR file.
  • *.exe *.txt *.rar are the files you wish to delete.  Here we have used wildcard specifications to indicate we want to delete all files that end in .exe, .txt, and .rar.  The reason I used *.rar as an example is that I found that I had accidentally archived archives in some of my backups, so I had backed up a backup unnecessarily.  I used this batch file technique to go in a clean them out.

Notice:  Xona.com holds no responsibility for any data loss you experience.  Make backups of your RAR files before you attempt to modify them, in case it does not work.  Double check your work.  If you have lots of RAR files, test the batch file on just a few of them (a few copies of them) first.  Do not delete files you are not one hundred percent certain you do not need.  Always make backups.

 

All WinRAR Tips:

 

Have Any Tips To Add?

If you have WinRAR tips you would like to add, please contact us.

 

Also See:

 

External Links:

 

By: Matthew Doucette
(Interested in Writing Articles For Xona.com?)



> Home
> Discuss
> Contact
  ©Xona.com™


Email:
Xona.com™ and Xona Games™ (formerly Xonatech™ & Saw Tooth Distortion™)
2,670,899 page views (since 2004-Jul-27)

Credit Card | Car Loan | Bankruptcy | Mortgage Calculator | Credit Card Consolidation