Welcome to WebmasterWorld Guest from 54.225.3.114

Forum Moderators: bill

Message Too Old, No Replies

automatically and recursively delete all html files in a folder

     
9:21 am on Feb 28, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:July 24, 2002
posts:1126
votes: 0


hi,

i'd like to recursively search through a folder and subfolders and delete all html files.

this should run on scheduler every morning for instance.

i am used to *nix (using cron and find) - is there a windows equivalent? (i run winxp pro)

many thanks

3:05 pm on Feb 28, 2006 (gmt 0)

Administrator

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
posts:12547
votes: 2


Windows has a job scheduler --
Start > Control Panel > Scheduled Tasks > Add Scheduled Task
where you could setup your own DEL (ERASE) command. I believe the syntax might be
DEL /S C:/PATH/TO/BASEDIR/*.html
Since a directory is specified, all files matching the wildcard in the directory should be deleted and the /S switch says to delete specified files from all subdirectories. You'll have to test this as my DOS programming is getting weak ;-)
1:41 am on Mar 1, 2006 (gmt 0)

Administrator from JP 

WebmasterWorld Administrator bill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Oct 12, 2000
posts:14976
votes: 131


Good suggestion coopster. You can use the scheduler to run DOS batch files at scheduled times to the same effect. My machines run through several self-cleaning batch files every night using Scheduled Tasks.

Here's some info on how to use batch files on XP from Microsoft: Using batch files [microsoft.com].

9:19 am on Mar 1, 2006 (gmt 0)

Moderator from US 

WebmasterWorld Administrator robert_charlton is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Nov 11, 2000
posts:11842
votes: 287


This thread reminds me that when there was a full DOS window, as in Windows 9x, I used to use batch files a lot. Some of the old DOS shareware utilities like pcopy (anyone remember pcopy?) and pdel were extremely versatile.

Now, I'm not using batch files at all. It helps to be reminded that they're still viable, but that basic disk level is so well hidden that it's almost a stretch for me. Any other references besides that Microsoft page to get the juices flowing?

2:06 am on Mar 2, 2006 (gmt 0)

Administrator from JP 

WebmasterWorld Administrator bill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Oct 12, 2000
posts:14976
votes: 131


Any other references besides that Microsoft page to get the juices flowing?

Actually one page up from that link I provided is the complete Command-line reference A-Z [microsoft.com] that you can use to make Windows do all the fun stuff. ;)
2:13 am on Mar 2, 2006 (gmt 0)

Administrator

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
posts:12547
votes: 2


I always figured MS was going to try and push folks away from the old commands once they had their own scripting engine in place. Nice to see some diehards still pushing the envelope ;)
2:44 am on Mar 2, 2006 (gmt 0)

Administrator from JP 

WebmasterWorld Administrator bill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Oct 12, 2000
posts:14976
votes: 131


My beta copy of Longhorn/Vista still has this function available, so it's a good trick to have in your bag.
4:18 am on Mar 2, 2006 (gmt 0)

Administrator

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
posts:12547
votes: 2


Oh, I'm sure it will remain for some time. What I meant was the scripting engine that came out so many years ago seemed like it was poised to replace the old DOS command line interface tools. I am with you though bill, I think we shall see the MS command line interface remain. Don't know how much they will build upon it, but I do think it is here to stay for awhile. You seeing anything new in the beta?
4:25 am on Mar 2, 2006 (gmt 0)

Administrator from JP 

WebmasterWorld Administrator bill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Oct 12, 2000
posts:14976
votes: 131


The beta I have installed is a bit old so I'm not seeing much yet. I need to find some time to install the recent CTP build [webmasterworld.com]. That's supposedly closer to being feature complete.

The real theme for Vista is security. It's safer out of the box. The good thing is that I'm not seeing them take away the configurable parts like our pal the Command Line. As long as my batch files will still work I'm happy. ;)

3:50 pm on Mar 2, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:July 24, 2002
posts:1126
votes: 0


coopster and bill,

thank you very much!

i'll play around with this and get back if i have problems,

cheers

2:19 pm on Mar 15, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:July 24, 2002
posts:1126
votes: 0


so....

i have used cooper's suggestion which works perfectly.

i have saved that line in a .bat file, but it won't run automatically via windows scheduler - is there any trick to that?

thanks

3:03 pm on Mar 15, 2006 (gmt 0)

Administrator

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
posts:12547
votes: 2


No, not really. Just make sure you have the correct permissions of course. Open up the Scheduled Task and look at it's properties. Go through each of them to make sure you have it set to run.