The following windows script will move files older than a given date from C:\folder1 to C:\folder2. By older, I am assuming that they are not modified after a certain date. The date is passed in the format yyyymmdd . When files are moved to folder2, they are automatically deleted from folder1.
# Script movefiles.txt
# Input argument - date
var str date
# Get a list of files not modified since $date.
var str list ; lf -n "*" "C:\folder1" ( ($ftype == "f") AND ($fmtime < $date) ) > $list
# Move files one by one.
while ($list <> "")
do
var str file ; lex "1" $list > $file
system move $file "C:\folder2"
done
The script is in biterscripting. Download biterscripting from http://www.biterscripting.com . Save the script as C:\Scripts\movefiles.txt. Start biterscripting. Call the script as script movefiles.txt date("20090613")
The above will move files that have not been modified since June 13, 2009 (30 days before today). Sen |
To delete all PDF files in a certain directory (say C:/Directory1), use this script.
# Script DeletePDF.txt
var str list ; lf -n "*.PDF" "C:/Directory1" > $list
while ($list <> "")
do
var str file ; lex "1" $list > $file
system -r del /FQ $file
done
Save the script as C:/Scripts/DeletePDF.txt, start biterscripting ( http://www.biterscripting.com ), enter the following command script "C:/Scripts/DeletePDF.txt" |