'$include "..\PURGE\Purge.WCS" sub Purge_Start ( \ byval Registration as string, \ byval Copyright as string ) ////////////////////////////////////////////////////////////////////// // Warning: sort strings limited to 10 characters each. // ////////////////////////////////////////////////////////////////////// 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 Count_Purge as integer dim File_Area_To_Purge as integer dim Include_Never_Delete as boolean dim Option as string*1 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 ? "."; 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 do if GetFileAbsolute ( File_Rec, Sort_Index ) then FileInfo ( File_Rec.Name, File_Rec.Area ) end if ? ? "Disk space available: "; ? FormatNumber ( GetDiskFree, "#,###,###,###" ) ? if not InputYesNo ( \ "Continue selecting files to purge? (Y/n): ", true ) then exit do end if Sort_Index = SortNext loop until Sort_Index < 1 end sub