MSFN Forum: cmd file to erase all, except one i want - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

cmd file to erase all, except one i want Rate Topic: -----

#1 User is offline   darksimoon 

  • Member
  • PipPip
  • Group: Members
  • Posts: 106
  • Joined: 29-May 05

Posted 31 July 2005 - 05:50 AM

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.


#2 User is offline   cyberhrc 

  • Newbie
  • Group: Members
  • Posts: 15
  • Joined: 29-July 05

Posted 31 July 2005 - 06:29 AM

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 :)

so
u got
YOURWALL.JPG
2.JPEG
3.JPEG
XXX.JPEG

delete JPEG's only and JPG is untouched and still remains with same functions as JPEG files
:thumbup

for other files i dont wanna talk i'm newbie here wih CMD, REG's etc :w00t:

This post has been edited by cyberhrc: 31 July 2005 - 06:32 AM


#3 User is offline   darksimoon 

  • Member
  • PipPip
  • Group: Members
  • Posts: 106
  • Joined: 29-May 05

Posted 31 July 2005 - 06:32 AM

its a nice suggestion and thank you very much but what should i do in case other file types ? :) for example txt files ? :)

#4 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,195
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 31 July 2005 - 06:38 AM

try something like this
@echo off
:: put the path to your files here
set pathto=E:\My Files\textfiles\test

:: put your file extension here
set extn=txt

:: put the filename without extension of the one you want keeping here
set tokeep=msfntest

pushd %pathto%
for %%a in (*.%extn%) do if "%%~a" neq "%tokeep%.%extn%" echo/del /q "%%~a"
popd&goto :eof
Remove the echo/ once you have verified it works.

Note - I have filled in after the equals symbols, only for information

This post has been edited by Yzöwl: 31 July 2005 - 06:41 AM


#5 User is offline   darksimoon 

  • Member
  • PipPip
  • Group: Members
  • Posts: 106
  • Joined: 29-May 05

Posted 31 July 2005 - 06:45 AM

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.

#6 User is offline   Thinkster 

  • Member
  • PipPip
  • Group: Members
  • Posts: 140
  • Joined: 17-September 04

Posted 31 July 2005 - 01:26 PM

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...

#7 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,195
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 31 July 2005 - 03:10 PM

@ Thinkster
That 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 enableextensions

for /d %%a in ("%AllUsersProfile%\..\*") do if exist "%%~a\Desktop\*.lnk" call :gothere "%%~a\Desktop"
endlocal&goto :eof

:gothere
pushd %1
for /f "delims=" %%b in ('dir /b/a-d "*.lnk"^|findstr/ivg:"%~dp0lnk2keep.txt"^2^>nul') do if errorlevel 0 del /q "%%~b"
popd&goto :eof 
now 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.lnk
Real Player.lnk
SpywareBlaster.lnk
With the above, all *.lnk files found on 'all users desktops' will be deleted unless they match the names listed in the text file.
</Edit>

This post has been edited by Yzöwl: 01 August 2005 - 05:00 AM


#8 User is offline   darksimoon 

  • Member
  • PipPip
  • Group: Members
  • Posts: 106
  • Joined: 29-May 05

Posted 31 July 2005 - 11:51 PM

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

#9 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,195
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 01 August 2005 - 05:04 AM

@ darksimoon
See 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

#10 User is offline   Achdine 

  • Junior
  • Pip
  • Group: Members
  • Posts: 97
  • Joined: 11-May 05

Posted 01 August 2005 - 08:03 AM

Quote

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.

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy