-
January 25th, 1999, 11:33 AM
#1
How to write a batch script to delete files older than 24 hours
Hello
I need help on how to delete files from a particular directory which are older than 24 hours.
please help
Thanks
Pinky
-
January 31st, 1999, 05:27 PM
#2
Dont know how to get it to run at a perticular time but this will do it for you every time you reboot.
1)add this line to your autoexec.bat neer the end
dump.bat (call it whatever.bat its gonna call the batch file you are gonna write.)
2)At the command prompt type "edit dump.bat"
this should give you a blank edit screen.
now add the 2 following lines
deltree /y path eg..(c:\windows\temp)
mkdir path eg..(c:\windows\temp)
**note** where I put path you put the path of the files you want to delete.
**Also note** that this is going to erase any subdirectory`s in the path so be carefull.
Save and exit, and the next time you reboot presto it completely wipes the directory and writes a new one with the same name over it. Works good for my old dos box.
Good Luck!!
-
February 1st, 1999, 10:23 AM
#3
I need to only delete files which are older than 24 hours, not all the files in the directory!!
-
February 4th, 1999, 07:40 AM
#4
Hi,
I don't know how to do this directly, but some archive utilities (ARJ for example) can add files to archive which are created before today or before number of days specified. For example, you can move files created before today to some temporary archive and then delete the archive.
Good luck, Igor M
Good luck, Igor
-
February 7th, 1999, 04:43 PM
#5
Hi,
Just as a though.
The Problem. Clean files in temp dir older than 24 hours.
Solution: Create a batch file that gets the systems date and creates a dir based on that information.
Example Today is 1-8-1999
In dos the dir will appear 1-8-19~
In explorer it will appear 1-8-1999
Next. After the dir is created all files in the targeted dir (temp) are moved to the dated dir. If you reboot the dir already exist so it will not be recreated. The only effect any files still there are moved to todays dir.
You may then add to the bat an if exist *-1-* rd *-1-* statement. Continueing on up to 30.
Well these thoughts are written on the fly and only intended to be some thoughts for considering.
If you wish to create the program and need some help on the dir/date code just email me.
I am not an expert so any advice by me should be weighed.
All spelling and grammitical errors in the above message are to considered (Copyright of World Library).
LOL LOL LOL
World Library
wlibrary@gdi.net
-
May 22nd, 2009, 05:31 PM
#6
biterscripting find command to find and delete files that are older than given date
Original poster says:
I need help on how to delete files from a particular directory which are older than 24 hours.
Here is a little script. I will assume folder is C:\folder. When you say 'older' than a certain time, I will assume you mean created before that certain time. I will assume that time is 20090522000000 (May 22, 2009, 00:00:00).
Code:
# Collect a list of files created before 20090522000000.
var str list ; find -rn "*" "C:\folder" ( 9$ftype=="f") AND ($fctime < "20090522000000") )
# Delete files in list one by one.
while ($list <> "")
do
var str file ; lex "1" $list > $file ; system delete ("\""+$file+"\"")
done
Script is in biterscripting (http://www.biterscripting.com/install.html). Translate it to any batch or scripting langugage of your choice.
Patrick
-
May 22nd, 2009, 11:24 PM
#7
Patrick, you did check the date on this thread, right. It's ten years old. Please don't resurrect any more older threads. I'm going to leave it open because it could help someone else.......if the script is true to course.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|