darksimoon Posted July 31, 2005 Share Posted July 31, 2005 hey friends its me again!i need a simple cmd file which can erase same kind of files in a folder except the one i determine. and it must be as simple as it can be because i wanna rearrange according to my needs.for example i wanna erase all *.jpeg files in %systemroot%\web\wallpaper except the one i wanna keep.can you help me pls. note:i have searched the forum and i've found similar topics but they were so complicated. Link to comment Share on other sites More sharing options...
cyberhrc Posted July 31, 2005 Share Posted July 31, 2005 (edited) well..since it's a picture format...why dont u rename that single wallpaper with JPEG extension into JPG and than u can freely delete all JPEG files coz this 1 is not JPEG anymore and it still remains like it is sou got YOURWALL.JPG2.JPEG3.JPEGXXX.JPEGdelete JPEG's only and JPG is untouched and still remains with same functions as JPEG files for other files i dont wanna talk i'm newbie here wih CMD, REG's etc Edited July 31, 2005 by cyberhrc Link to comment Share on other sites More sharing options...
darksimoon Posted July 31, 2005 Author Share Posted July 31, 2005 its a nice suggestion and thank you very much but what should i do in case other file types ? for example txt files ? Link to comment Share on other sites More sharing options...
Yzöwl Posted July 31, 2005 Share Posted July 31, 2005 (edited) try something like this@echo off:: put the path to your files hereset pathto=E:\My Files\textfiles\test:: put your file extension hereset extn=txt:: put the filename without extension of the one you want keeping hereset tokeep=msfntestpushd %pathto%for %%a in (*.%extn%) do if "%%~a" neq "%tokeep%.%extn%" echo/del /q "%%~a"popd&goto :eofRemove the echo/ once you have verified it works.Note - I have filled in after the equals symbols, only for information Edited July 31, 2005 by Yzöwl Link to comment Share on other sites More sharing options...
darksimoon Posted July 31, 2005 Author Share Posted July 31, 2005 hey friend (Yzöwl)thank you very much for your help you're repling my two questions. as a matter of fact i wanted to thank you after trying your suggestions. but your quick responce made me so happy. and i didnt wanted to wait for a thank. Link to comment Share on other sites More sharing options...
Thinkster Posted July 31, 2005 Share Posted July 31, 2005 I'm looking to do something similar to that in that I want to maintain a set of desktop icons (shortcuts) that are approved like 'My Documents' 'My Computer' 'Internet Explorer' 'Firefox' 'Real Player', etc. then if someone adds a shortcut or saves a file to the desktop to have it automatically deleted each time windows is booted (doesn't matter at which point).I'm thinking I need to store the approved shortcut names in a file or somewhere in the actual command script and have some kind of command that compares the current desktop files/shortcuts to what's supposed to be there and if something doesn't match, Delete it... Link to comment Share on other sites More sharing options...
Yzöwl Posted July 31, 2005 Share Posted July 31, 2005 (edited) @ ThinksterThat shouldn't be necessary for most of the ones you've mentioned, as they are not shortcuts and will not be found in the Desktop folder.<Edit>Here is an example, however, of something you could use@echo off&setlocal enableextensionsfor /d %%a in ("%AllUsersProfile%\..\*") do if exist "%%~a\Desktop\*.lnk" call :gothere "%%~a\Desktop"endlocal&goto :eof:gotherepushd %1for /f "delims=" %%b in ('dir /b/a-d "*.lnk"^|findstr/ivg:"%~dp0lnk2keep.txt"^2^>nul') do if errorlevel 0 del /q "%%~b"popd&goto :eofnow you will need a txt file named lnk2keep.txt, to be kept in the same location as this cmd file. Each line of the txt file will contain the names of the files you wish to keep.example:Firefox.lnkReal Player.lnkSpywareBlaster.lnkWith the above, all *.lnk files found on 'all users desktops' will be deleted unless they match the names listed in the text file.</Edit> Edited August 1, 2005 by Yzöwl Link to comment Share on other sites More sharing options...
darksimoon Posted August 1, 2005 Author Share Posted August 1, 2005 one more thing;i have wanted this except one file. can we extend this except two or three or ect. files ? what i wanna do is clean my wallpaper content except the ones i like.thanks in advance Link to comment Share on other sites More sharing options...
Yzöwl Posted August 1, 2005 Share Posted August 1, 2005 @ darksimoonSee if you can put something together, using the ideas from my last response to you and the Edit I've added to Thinkster's reply Link to comment Share on other sites More sharing options...
Achdine Posted August 1, 2005 Share Posted August 1, 2005 i have wanted this except one file. can we extend this except two or three or ect. files ? what i wanna do is clean my wallpaper content except the ones i like. Remove the ones you don't like from your install CD, then you won't need to worry about it at all. Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now