Brian Jester Posted August 22, 2008 Posted August 22, 2008 (edited) Hi again,I have another dilema...I am now trying to delete a certain type of file from inside the archives (zip / rar) that are sub-directories deep...Let me explain the folder structure:Games > 2000 > 2001 > 2002 > 2003 > 2004 > 2005 > 2006 > 2007 > 2008For example: You have have in the 2000 folder (note 2000 is a subfolder under Games) file.zip or file.rar. I need to delete a file inside file.zip or file.rar (depending what archive type is in that folder). I already tried using this code, but unfortuanetly it won't delete inside the archive if it's inside sub-folders. I've tried something like this:for %%i in (*.zip) do "WinRAR.exe" d -r %%i *.aviBut that will only work if the the batch file is in the same directory as the archives. I need to be able to work recursively. I just looked in the Winrar help file, but this doesn't seem possible using the 'd' command with the -r switch...Is there another way to accomplish this task?Hello, is there not a single soul that can help me get this code to work? Or something entirely different that will work?Thanks again!-Brian Edited August 22, 2008 by Brian Jester
jaclaz Posted August 22, 2008 Posted August 22, 2008 I am not sure to have understood whther the required "recursiveness" that you need is in the drive directory structure or within the .RAR archives. For "external" recursiveness, you may want to READ some info on the FOR switches:http://www.robvanderwoude.com/for.htmlhttp://www.robvanderwoude.com/ntfor.htmlthe /R one appears to be the one you are missing:FOR /R [[drive:]path] %variable IN (set) DO command [command-parameters]Walks the directory tree rooted at [drive:]path, executing the FOR statement in each directory of the tree.If no directory specification is specified after /R then the current directory is assumed.If set is just a single period (.) character then it will just enumerate the directory treeIf we are talking about files inside "sub-directories" within the archive, a more complex batch script is needed, using the command line version of Winrar, rar.exe, from WinRar help file (that you should have already READ ):Additionally to WinRAR you will find, in the distributive, the file rar.exe. It is also a 32-bit RAR version for Windows, but it supports only the command line, text mode interface. It is useful to call console RAR from BAT and CMD files, to use it at the DOS prompt and so on. It supports a larger number of command line switches and commands when compared with WinRAR. Though common aspects of the command line WinRAR syntax considered in Command line interface chapter are also true for console RAR, this help file does not contain descriptions of those switches and commands, which are supported only by the console version. You should read rar.txt file for a detailed description of all console RAR features.(bolding is mine)an online version of rar.txt can be found here:http://ams.cern.ch/AMS/amsexch/arch/rar/rar.txtjaclaz
Brian Jester Posted August 22, 2008 Author Posted August 22, 2008 I am not sure to have understood whther the required "recursiveness" that you need is in the drive directory structure or within the .RAR archives. unsure.gifAfter checking through my folder structure, I am going to need recursive(ness) in both, the directory structure as well as inside the rar and zip filesCan you post the code to do this? I am lost with the for /RThank you-Brian
jaclaz Posted August 22, 2008 Posted August 22, 2008 Can you post the code to do this? I am lost with the for /RNo, I won't , but I will support you in writing it .Start from something simple (forget for the moment about winrar/rar):@ECHO OFFSETLOCAL ENABLEEXTENSIONSfor /R "C:\GamesX" %%A in (*.rar) do ECHO %%A(supposing that "GamesX" directory is in ROOT of C:\ and contains just a few files in various nested subdirectories - including some .rar archives containing some .avi files - a FAKE structure for easy and fast testing)What happens? Now, supposing that you have rar.exe in "C:\Program Files\Winrar\" try this:@ECHO OFFSETLOCAL ENABLEEXTENSIONSfor /R "C:\GamesX" %%A in (*.rar) do (ECHO %%A"C:\Program Files\Winrar\rar.exe" lb %%A)What happens? Let's go one step further:@ECHO OFFSETLOCAL ENABLEEXTENSIONSfor /R "C:\GamesX" %%A in (*.rar) do (ECHO %%A"C:\Program Files\Winrar\rar.exe" lb %%A | FIND ".avi")What happens? jaclaz
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now