Fascix Posted June 10, 2005 Share Posted June 10, 2005 (edited) HiI was just woundering if there is a command to exclude one or two files when i use the:DEL "%systemroot%\*.log"I dont want the WindowsUpdate.log to be deletedOr do i then have to specify ALL the different *.log files i want to be deleted?And if i want to keep more than one file, how do i specify that?Also what are the different "Easy Paths"? like:%systemroot% = Windows dir%windir% = Is this the same? (dont know)%systemdrive% = X:\ (where x is the drive that windows is installed to)%ProgramFiles% = Program dir (specified in winnt.sif)%CommonProgramFiles% = Common Program files dir (can also be specified in winnt.sif)%CDROM% = The CDRom DriveI am doing my Cleanup.cmd file now and paths like the ones above can really helpbut the main question is main priority Thanx people! Edited June 10, 2005 by Fascix Link to comment Share on other sites More sharing options...
gunsmokingman Posted June 10, 2005 Share Posted June 10, 2005 Here A VBS File That Should Remove What You Need And Leave What You WantOn My Test it Left All Log File With W in WindowsSave As RemoveLog.Vbs Function RmLogFile Dim objLc : Set objLc = CreateObject("Wscript.shell") LACT = objLc.ExpandEnvironmentStrings("%SystemDrive%\Windows") F1 = LACT F2 =Array ((F1 & "\0.log"), (F1 & "\1.log"), (F1 & "\2.log"), (F1 & "\3.log"), (F1 & "\4.log"),_ (F1 & "\5.log"), (F1 & "\6.log"), (F1 & "\7.log"), (F1 & "\8.log"), (F1 & "\9.log")) F3 = Array ( (F1 & "\A.log"), (F1 & "\B.log"), (F1 & "\C.log"), (F1 & "\D.log"), (F1 & "\E.log"),_ (F1 & "\F.log"), (F1 & "\G.log"), (F1 & "\H.log"), (F1 & "\I.log"), (F1 & "\J.log"), (F1 & "\K.log"),_ (F1 & "\L.log"), (F1 & "\M.log"), (F1 & "\N.log"), (F1 & "\O.log"), (F1 & "\P.log"), (F1 & "\Q.log"),_ (F1 & "\R.log"), (F1 & "\S.log"), (F1 & "\T.log"), (F1 & "\U.log"),(F1 & "\V.log"), (F1 & "\W.log"),_ (F1 & "\X.log"), (F1 & "\Y.log"), (F1 & "\Z.log")) On Error Resume Next Fso.DeleteFile (F2(0)) Fso.DeleteFile (F2(1)) Fso.DeleteFile (F2(2)) Fso.DeleteFile (F2(3)) Fso.DeleteFile (F2(4)) Fso.DeleteFile (F2(5)) Fso.DeleteFile (F2(6)) Fso.DeleteFile (F2(7)) Fso.DeleteFile (F2(8)) Fso.DeleteFile (F2(9)) Fso.DeleteFile (F3(0)) 'A Fso.DeleteFile (F3(1)) 'B Fso.DeleteFile (F3(2)) 'C Fso.DeleteFile (F3(3)) 'D Fso.DeleteFile (F3(4)) 'E Fso.DeleteFile (F3(5)) 'F Fso.DeleteFile (F3(6)) 'G Fso.DeleteFile (F3(7)) 'H Fso.DeleteFile (F3(8)) 'H Fso.DeleteFile (F3(9)) 'J Fso.DeleteFile (F3(10)) 'K Fso.DeleteFile (F3(11)) 'L Fso.DeleteFile (F3(12)) 'M Fso.DeleteFile (F3(13)) 'N Fso.DeleteFile (F3(14)) '0 Fso.DeleteFile (F3(15)) 'P Fso.DeleteFile (F3(16)) 'Q Fso.DeleteFile (F3(17)) 'R Fso.DeleteFile (F3(18)) 'S Fso.DeleteFile (F3(19)) 'T Fso.DeleteFile (F3(20)) 'U Fso.DeleteFile (F3(21)) 'V ' Fso.DeleteFile (F3(22)) 'W Fso.DeleteFile (F3(23)) 'X Fso.DeleteFile (F3(24)) 'Y Fso.DeleteFile (F3(25)) 'Z End Function RmLogFile For The Cdrom you need to set the varible for itHere are 2 different ways to do it,FOR /F "TOKENS=3" %%I IN ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "SourcePath" ^| FINDSTR "SourcePath"') DO SET CDROM=%%~dIfor %%i in (C: D: E: F: G: H: I: J: K: L: M: N: O: P: Q: R: S: T: U: V: W: X: Y: Z:) do if exist %%i\SETUP.exe set CDROM=%%i Link to comment Share on other sites More sharing options...
Martin Zugec Posted June 10, 2005 Share Posted June 10, 2005 For /f "usebackq" %%i IN (`dir /b %windir%\*.log`) DO If %%i NEQ WindowsUpdate.log del /q %%i Link to comment Share on other sites More sharing options...
enuffsaid Posted June 10, 2005 Share Posted June 10, 2005 Nice command there, Martin! Link to comment Share on other sites More sharing options...
Martin Zugec Posted June 10, 2005 Share Posted June 10, 2005 Simple commands = nice command Link to comment Share on other sites More sharing options...
enuffsaid Posted June 10, 2005 Share Posted June 10, 2005 It sure beats the 30+ lined VB script. Link to comment Share on other sites More sharing options...
Fascix Posted June 10, 2005 Author Share Posted June 10, 2005 (edited) Hey Martin ZugecI tried your command but it seems to search for the files in C:\...So nothing happends!I changed the %windir% to %systemroot% and i tried to specify it whit: C:\Windows in your command line... do i need to execute it from somewhere special?gunsmokingmani haven´t tried yours yet. but if i want this script for say *.txt files i just change the *.log from everywhere in the script to *.txt right and then use the little ' mark on the letter of the filename i want to exclude right? And its alright to call upon this from cleanup.cmd right?thanx Edited June 10, 2005 by Fascix Link to comment Share on other sites More sharing options...
Martin Zugec Posted June 10, 2005 Share Posted June 10, 2005 Works fine on mine pc, I tried it... What OS are you using?The script is not dependent on actual path. Link to comment Share on other sites More sharing options...
Fascix Posted June 10, 2005 Author Share Posted June 10, 2005 Martin ZugecOkey i actually did this I did a file called test.cmd in my root (c:\)then i put your command line in it and ended it whit pausethen i change the *.log entries in the cmd file to *.qaz(and WindowsUpdate.log to WindowsUpdate.qaz)then i just created some *.qaz files and the WindowsUpdate.qaz in my windows dirthen i executed the test.cmd file and it didnt workI did this just to test and see if it did indeed deleate just the other *.qaz files but not the WindowsUpdate.qazI use Windows XP sp2 Link to comment Share on other sites More sharing options...
Martin Zugec Posted June 10, 2005 Share Posted June 10, 2005 Ok, try this:For /f "usebackq" %%i IN (`dir /b %windir%\*.log`) DO If %%i NEQ WindowsUpdate.log echo %%i >> c:\test.logAnd post the test.log to see what happens Link to comment Share on other sites More sharing options...
Fascix Posted June 10, 2005 Author Share Posted June 10, 2005 (edited) Hmmm okey i tríed it but the test.log is empty!!!? Edited June 10, 2005 by Fascix Link to comment Share on other sites More sharing options...
Martin Zugec Posted June 10, 2005 Share Posted June 10, 2005 For /f "usebackq" %%i IN (`dir /b %windir%\*.log`) DO If %%i NEQ WindowsUpdate.log echo %%iPauseAnd try to post the content of cmd window Link to comment Share on other sites More sharing options...
Yzöwl Posted June 10, 2005 Share Posted June 10, 2005 (edited) soulins Martins command is fine, the only possible changes I would make, even though they shouldn't matter as far as 'not working' is concerned isfor /f %%i in ('dir "%windir%\*.log" /b') do if %%i neq windowsupdate.log echo del /q "%%~fi"<Edit>When you have verified the screen output, remove 'echo '</Edit> Edited June 10, 2005 by Yzöwl Link to comment Share on other sites More sharing options...
enuffsaid Posted June 10, 2005 Share Posted June 10, 2005 (edited) I tried Martin's original command...When I ran that batch file from the C:\ drive it gave me errors it couldn't find the particular logfile in C:\But, when I ran it from C:\Windows it worked fine.Hope that helps.Edit... works like a charm for me. Re-ran it, and it didn't find anymore files. WindowsUpdate.log is still there. Edited June 10, 2005 by enuffsaid Link to comment Share on other sites More sharing options...
Yzöwl Posted June 10, 2005 Share Posted June 10, 2005 To be honest, I wouldn't even bother with the batch, just paste the following into the Start > Run box and click OKcmd /c for /f %i in ('dir "%windir%\*.log" /b') do if %i neq windowsupdate.log del /q "%~fi" Link to comment Share on other sites More sharing options...
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