'$include "EvalPurg.WCS" sub Purge_Start ( \ byval Registration as string, \ byval Copyright as string ) ////////////////////////////////////////////////////////////////////// // Warning: sort strings limited to 10 characters each. // ////////////////////////////////////////////////////////////////////// dim Count as long dim DiskToo as boolean dim File_Count as long dim Sort_Index as long dim File_Rec as FileRecord dim Days as integer dim Days_Min as integer dim Default as string*1 dim Count_Purge as integer dim File_Area_To_Purge as integer dim Include_Never_Delete as boolean dim Option as string*1 dim Rating as real dim Sort_Str_1 as string*10 dim Sort_Str_2 as string*10 dim Sort_Str_Cost as string*5 dim Sort_Str_Days as string*4 dim Sort_Str_Downloads as string*10 dim Sort_Str_Size as string*10 dim Test as integer ////////////////////////////////////////////////////////////////////// cls ? COPYRIGHT ? "Registration: "; Registration ? ? "This program will sort those files over a user-specified number" ? "of days old by cost then byte size. Use this utility to purge" ? "those files that are low in cost but big in file size. If all" ? "of your files have zero cost, they will sorted simply by size." ? "Files marked free or never delete will not be considered." ? "You will be prompted to delete files as you go." ? "Multi-node usage has not been tested." ? if Registration = UNREGISTERED then ? "You should register this program if you find it useful." end if ? ? "Disk space available: "; ? FormatNumber ( GetDiskFree, "#,###,###,###" ) ? ? "Minimum age of file to sort for purge in days? "; Days_Min = Integer_Ask ( "", 0, 32767, 60 ) ? ? "1) Sort by lowest cost, then largest byte size" ? "2) Sort by lowest cost, then least downloads" ? "3) Sort by least downloads, then oldest" ? "A) Abort/Quit" ? ? "Option [A]: "; input Option if ( Option <> "1" ) and ( Option <> "2" ) and ( Option <> "3" ) then Option = "A" end if if ( Option = "A" ) or ( Option = "a" ) then ? "Aborted." WaitEnter exit sub end if Include_Never_Delete = InputYesNo ( \ "Include files marked NEVER DELETE? (y/N): ", false ) Test = MakeWild.MaxFileAreas File_Area_To_Purge = Integer_Ask ( \ "File area to purge? [0=All]: ", 0, Test, 0 ) ? ? "This will take a while to sort. Abort now?"; if InputYesNo ( " (y/N): ", false ) then ? "Aborted." WaitEnter exit sub end if MorePrompt Off SortStart File_Count = 0 Sort_Index = 0 Count_Purge = 0 do if Inkey <> "" then ? if not InputYesNo ( \ "Key pressed. Continue search? (y/N): ", false ) then exit do end if ? end if ? "."; Sort_Index = Sort_Index + 1 if GetFileAbsolute ( File_Rec, Sort_Index ) then File_Count = File_Count + 1 if ( File_Area_To_Purge = 0 ) or ( File_Rec.Area = File_Area_To_Purge ) then if not File_Is_Free ( File_Rec ) then if Include_Never_Delete or not File_Is_Never_Delete ( File_Rec ) then if Days_Since ( File_Rec.FileTime ) >= Days_Min then Sort_Str_Cost = FormatNumber ( File_Rec.Cost, "@####" ) Days = Days_Since ( File_Rec.FileTime ) Sort_Str_Days = \ FormatNumber ( 9999 - Days, "@###" ) Sort_Str_Downloads = \ FormatNumber ( File_Rec.Downloads, "@####" ) Sort_Str_Size = \ FormatNumber ( 2147483647 - File_Rec.Size, "@#########" ) if Option = "1" then Sort_Str_1 = Sort_Str_Cost Sort_Str_2 = Sort_Str_Size elseif Option = "2" then Sort_Str_1 = Sort_Str_Cost Sort_Str_2 = Sort_Str_Downloads else Sort_Str_1 = Sort_Str_Downloads Sort_Str_2 = Sort_Str_Days end if ? ? FormatNumber ( Sort_Index, "@#########" ); " "; ? FormatNumber ( File_Count, "@#########" ); " "; ? "$"; FormatNumber ( File_Rec.Cost / 100, "@##.##" ); " "; ? Pad ( FormatNumber ( File_Rec.Size, "#,###,###,###" ), 15 ); ? Sort_Str_Downloads; " "; ? Pad ( FormatNumber ( Days, "#,###" ), 7 ); ? File_Rec.Name if Days > 9999 then WaitEnter end if SortAdd ( Sort_Str_1 + Sort_Str_2, Sort_Index ) Count_Purge = Count_Purge + 1 end if end if end if end if end if if File_Count >= MasterInfo.TotalFiles - 100 then exit do end if loop ? ? Count_Purge; " files found for possible purge." WaitEnter MorePrompt On if Count_Purge <= 0 then exit sub end if Sort_Index = SortNext Default = "S" do if GetFileAbsolute ( File_Rec, Sort_Index ) then if not Eval_Rec_Get ( Rating, Count, File_Rec.Name, Config.Bias_Count ) then Rating = 1.0 Count = 0 end if do EvalFile_FileInfo_Show ( File_Rec, Rating, Count ) ? "Disk: "; ? Trim ( FormatNumber ( GetDiskFree, "#,###,###,###" ) ); " "; ? "(D)elete, "; if File_Is_Never_Delete ( File_Rec ) then ? "un"; end if ? "(M)ark never delete, (Q)uit, (S)kip ["; Color ( 12 ) ? Default; Color ( 15 ) ? "]: "; input Option if Option = "" then Option = Default end if Option = Ucase ( Trim ( Left ( Option, 1 ) ) ) if Option = "D" then if not File_Is_Never_Delete ( File_Rec ) then DiskToo = InputYesNo ( "Delete file from disk, too? (Y/n): ", true ) if InputYesNo ( "Are you sure you want to delete this file? (Y/n): ", true ) then if DeleteFile ( File_Rec.Name, File_Rec.Area, DiskToo ) then ? "File deleted." WaitEnter exit do else ? "File deletion FAILED." WaitEnter end if end if else ? "This file has been marked NEVER DELETE." ? "You must unmark it before deleting." WaitEnter end if elseif Option = "M" then if File_Is_Never_Delete ( File_Rec ) then ? "Unmarking file never delete..."; if File_Never_Delete_Unmark ( File_Rec ) then ? "done." else ? "failed." end if WaitEnter else ? "Marking file never delete..."; if File_Never_Delete_Mark ( File_Rec ) then ? "done." WaitEnter exit do else ? "failed." end if WaitEnter end if elseif Option = "Q" then exit do elseif Option = "S" then exit do else Beep end if loop if Option = "Q" then exit do end if end if Sort_Index = SortNext loop until Sort_Index < 1 end sub