Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Winrar command line question..

Status
Not open for further replies.

Hagfish

MIS
Jan 20, 2005
88
US
I need to use winrar to archive a heavily trafficked directory containing several gigs of data, that needs to be purged periodically.. I set this up by using the following command..

winrar a -v4294967 -ep2 -r -tb2007-02-15 -df "c:\test.rar" "C:\test\*.*"

It works great, but here's the problem, that -df switch, which deletes the file after it's been archived, also deletes the folder!! I need to keep the folder shell/structure intact and only delete the files. Any help appreciated..
 
Hi, Hagfish

Sorry, don't know about Winrar.
However, if you put a hidden, read-only file in the folder that should make it pretty hard to delete the folder.

Jock
 
No solution - but I can offer two possible workarounds.

1.

Arrange somehow to 'touch' all the folders so that their modified date is later than the winrar selection date.


2.

Providing all your folders have no extension and all of the files you want to archive do have an extension then archive the folders only and re-create them afterwards using a batch file thus.

winrar a -v4294967 -ep2 -r -tb2007-02-15 -df "c:\testdirs.rar" "C:\test\*."
winrar a -v4294967 -ep2 -r -tb2007-02-15 -df "c:\test.rar" "C:\test\*.*"
winrar x "c:\testdirs.rar"

I have been known to be wrong.
The best way to thank someone who helps you is give them a star.
 
Thanks for the suggestions.. I don't necessarily have to use winrar.. Any of you use any folder archiving software that's either free or avail for purchase? I wish windows had a freakin folder archiving utility built in..
 
OK, so don't let winrar delete the files, do it yourself in a second line in the batch file:

del c:\test\*.* /s /q

That will leave the empty directory structure intact.

I don't let the archive program delete the source because I want to test the integrity of the archive first. Then do something like the above based on errorlevel.

Not having archive programs part of the OS has led to a good deal of innovation in that area.

Jock
 
Yeah, the only prob there is that I need to leave the 2 most current weeks of files and not delete everything in those directories, so I really couldn't just run generic "delete all" type of command.. I think I have found a workaround though..

Winrar supports list files, and the files I'm archiving in these directories are really only two or three types. Therefore I can do the following

winrar a -v4294967 -ep2 -r -tb2007-02-15 -df "c:\test.rar" @"c:\list.lst"

list.lst looks like this:
c:\test\*.zip
c:\test\*.pdf

This deletes the zip and pdf files, but leaves the directories intact. I guess *.* is just too inclusive.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top