Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   Dev Hardware ForumsSOFTWAREProgramming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Hardware Forums Sponsor:
  Trader Rating: 0 · #1  
Old February 26th, 2008, 10:04 AM
jmcall10 jmcall10 is offline
n00b DevH'er
Dev Hardware Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 3 jmcall10 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 50 sec
Reputation Power: 0
Post DOS Batch - Deleting files older than a week

Hi, this may have been covered however I cant seem to find what im looking for.

At present I have:

Code:
@echo off
rem .:------------------------------------------
rem .: Deleting contents of scans
rem .:------------------------------------------

del "G:\Scans\*.*"


This works well for deleting all the files withing the Scans folder.

I want to adapt this now so it deletes only the files that are 1 week old.

How would I change the code to achieve this?

Thanks in advance

jmcall10

Reply With Quote
  Trader Rating: 1 · #2  
Old February 26th, 2008, 10:42 AM
weevilofdoom's Avatar
weevilofdoom weevilofdoom is online now
BLURG
Dev Hardware Loyal (3000 - 3499 posts)
 
Join Date: Sep 2004
Location: Oregon
Posts: 3,418 weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)  Folding Points: 32443 Folding Title: Starter FolderFolding Points: 32443 Folding Title: Starter Folder
Time spent in forums: 2 Months 20 h 45 m 35 sec
Reputation Power: 3311
Send a message via ICQ to weevilofdoom Send a message via AIM to weevilofdoom Send a message via MSN to weevilofdoom Send a message via Yahoo to weevilofdoom Send a message via Google Talk to weevilofdoom
I would recommend getting the FORFILES.EXE from the Resource Kit tools released from Microsoft, then you can just do this:

FORFILES -pc:\foldername -s -m*.* -d-30 -c"CMD /C del @FILE"

-p = path
-s = include subdirs
-m = match filetype
-d = age in days (can also be set as an absolute date ie DDMMYYYY)
-c = command to execute

Note there are no spaces between the switches and their arguments.

http://www.dynawell.com/support/ResKit/winnt.asp
__________________

Reply With Quote
  Trader Rating: 0 · #3  
Old February 26th, 2008, 10:58 AM
jmcall10 jmcall10 is offline
n00b DevH'er
Dev Hardware Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 3 jmcall10 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 50 sec
Reputation Power: 0
Hmm, this is on a work computer so wont be able to install anything

Is there another way that I can do this?

thanks for your response

Reply With Quote
  Trader Rating: 1 · #4  
Old February 26th, 2008, 11:35 AM
weevilofdoom's Avatar
weevilofdoom weevilofdoom is online now
BLURG
Dev Hardware Loyal (3000 - 3499 posts)
 
Join Date: Sep 2004
Location: Oregon
Posts: 3,418 weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)  Folding Points: 32443 Folding Title: Starter FolderFolding Points: 32443 Folding Title: Starter Folder
Time spent in forums: 2 Months 20 h 45 m 35 sec
Reputation Power: 3311
Send a message via ICQ to weevilofdoom Send a message via AIM to weevilofdoom Send a message via MSN to weevilofdoom Send a message via Yahoo to weevilofdoom Send a message via Google Talk to weevilofdoom
I'm afraid it would be a lot harder to do with batch ... have you looked into doing VBS or something? That'd be simple enough...

Reply With Quote
  Trader Rating: 0 · #5  
Old February 27th, 2008, 02:52 AM
jmcall10 jmcall10 is offline
n00b DevH'er
Dev Hardware Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 3 jmcall10 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 50 sec
Reputation Power: 0
ive never touched vb scrpiting.

How would I code the same thing in vbscript?

Thanks in advance

jmcall10

Reply With Quote
Reply

Viewing: Dev Hardware ForumsSOFTWAREProgramming > DOS Batch - Deleting files older than a week


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway