@ Yellowblock
the date should be future date , it means if todays date is 8-18-2010
i want a delete a file or folder or drive on 8-25-2010
I am not sure if I fully understand, but sounds to me that you want to delete a file "deleteit.txt" that is a week old. There are multiple files called "deleteit.txt" on the drive, and you want to delete the one that was last modified a week ago.
Here is a script
Code:
# Script Delete7days.txt
# Input arguments - drive letter, file name
var string drive, name
# Other variables
var string list, file, targettime
# Check if arguments assigned.
if ($drive=="") or ($name=="")
exit 1 "Error: Input arguments not assigned. Usage: script "Delete7days.txt" drive("D:/") file("deleteit.txt")
endif
# Target time is now - 7 days.
set $targettime = addtime( diff("-7000000") )
# Get a list of files that were modified earlier than $targettime.
lf -r -n $name $drive ($fmtime < $targettime) > $list
# Delete file.
while ($list <> "")
do
lex "1" $list > $file
system delete ("\""+$file+"\"")
done
The "-7000000" means subtract 7 days, 00 hours, 00 mins, 00 seconds from current time. See the documentation for function addtime().
Save the script in file C:/Scripts/Delete7days.txt. Create a shortcut on desktop and assign it this command.
Code:
"C:/biterscripting/biterscripting.ex" "C:/Scripts/Delete7days.txt" drive("D:/
") name("deleteit.txt")
Each time you double click this icon, it will delete the file "deleteit.txt" that was modified 7 days ago from drive D:/.
Bookmarks