Would like to know from Window Users, how many Backup Data Files are you saving?

2»

Comments

  • SnowmanSnowman Member
    edited December 2018
    Jerry I do manual backups to an NAS drive that is backed up to another NAS drive and every 3 months I make a backup that goes offsite to a bank safe deposit box 15 miles from my location.
    I use the option to add the date and time to the name of the backup file.  I have added a backup icon to the Quicken toolbar.  EVERY time I exit from Quicken when I have changed data create a backup.  There are days were I overwrite that backup file for that "day" so I have the most recent.
    I keep up to 365 (1 year) of backup files on the NAS drive.  While this may seem like overkill I had an instance a couple of years back my main checking account was corrupted and I did not know it until 7 months later.  By going back I found the day the corruption took place and fixed my file.  I have the NAS drive mapped in Windows 10 as the "A" drive.
  • Jerry_Jerry_ Member
    edited May 2018
    Snowman said:

    Jerry I do manual backups to an NAS drive that is backed up to another NAS drive and every 3 months I make a backup that goes offsite to a bank safe deposit box 15 miles from my location.
    I use the option to add the date and time to the name of the backup file.  I have added a backup icon to the Quicken toolbar.  EVERY time I exit from Quicken when I have changed data create a backup.  There are days were I overwrite that backup file for that "day" so I have the most recent.
    I keep up to 365 (1 year) of backup files on the NAS drive.  While this may seem like overkill I had an instance a couple of years back my main checking account was corrupted and I did not know it until 7 months later.  By going back I found the day the corruption took place and fixed my file.  I have the NAS drive mapped in Windows 10 as the "A" drive.

    Snowman, Thanks for your information. Oh, what to do? (lol) I have up my File Retention to 90 days in the Script. Your keeping up to 365 days is a thought.

    Again, thanks for your input.


    Now running the 2019 Windows Subscription Plan
    Retired - former Computer System Analyst
  • Jerry_Jerry_ Member
    edited May 2018
    Jerry said:

    Clayton is your Account in your Window OS flagged as Administrator or Standard?

    Another thought occurred to me.

    You did show that your Set command appears as such;
    (set Bkupfolder="E:\Users\Clayton\Documents\Quicken\Backup").

    Remove the quote marks on the right side of the equate sign.
    Now running the 2019 Windows Subscription Plan
    Retired - former Computer System Analyst
  • Jerry_Jerry_ Member
    edited May 2018
    Jerry said:

    Clayton is your Account in your Window OS flagged as Administrator or Standard?

    Another thought occurred to me.

    You did show that your Set command appears as such;
    (set Bkupfolder="E:\Users\Clayton\Documents\Quicken\Backup").

    Remove the quote marks on the right side of the equate sign.
    Now running the 2019 Windows Subscription Plan
    Retired - former Computer System Analyst
  • ClaytonClayton Member
    edited May 2018
    Jerry said:

    Clayton is your Account in your Window OS flagged as Administrator or Standard?

    Big grin! It was the Quotes! I've never had that happen before with long names. 

    And the Delete Folder.bat is a dangerous little thing. It WILL delete a folder no matter what the attributes or ownership.
    +++++++++++++++++++++++++
    Delete File/Folder bat:

    : Drag & drop the undeletable folder onto the icon of this batch script
    :(make sure it’s the right folder!). Remove the batch file when done.
    :
    :
    Rem rd /s /q \\?\%1
    :
    :
    : Drag & drop the undeletable file onto the icon of this batch script
    :(make sure it’s the right file!). Remove the batch file when done.
    :
    :
    Rem del /s /q \\?\%1
    +++++++++++++++++++++++++

    Thank you and enjoy your weekend.
  • Jerry_Jerry_ Member
    edited May 2018
    Jerry said:

    Clayton is your Account in your Window OS flagged as Administrator or Standard?

    GREAT!!

    By the way, if you haven't already, trigger "Command Prompt" and execute a "help del" command. You will find a Switch "/A" where you can select files with certain attributes to delete.


    Now am enjoying my weekend. Do likewise!! (grin)
    Now running the 2019 Windows Subscription Plan
    Retired - former Computer System Analyst
  • ClaytonClayton Member
    edited May 2018
    Jerry said:

    Clayton is your Account in your Window OS flagged as Administrator or Standard?

    I'd already done some "research" on your use of the switches and variables. 

    You're better at this than I am!

    Again, THANKS.
  • Jerry_Jerry_ Member
    edited November 2018





    Clayton Thanks for posting a batch script. I forgot about utilizing the colon (:) to show a blank line in a script. However, I do employ it on the Label lines. Go figure!! (LOL)

    Folks, with that in mind, I have resubmitted my script utilizing colon lines; made a correction to the script, and added personnel user data to the script.

    To all viewing this Post, feel free to copy it to your System to utilize and to enjoy.


    @Echo off

    color 4f
    rem color f0
    title Quicken Backup Data File Clean-Up Utility
    setlocal enableextensions
    :
    rem         Data File Utility in working with Quicken Data Backups
    rem       To be utilized with Windows 7 and above Operating Systems.             
    rem                   (Date format = (06/08/2015)                              
    rem             (Time format = (13:05 - 24 hour setting)                     
    rem           (Backup Drive = E - External Portable Drive)                   
    :
    rem        Please replace the following (SET) line with you own            
    rem                       Directory location                            
    set Bkupfolder=E:\Quicken Data Backups
    :
    rem      Retrieving Personal data of the User and Captializing
    rem      the First Letter of the Name
    for /f "tokens=1-2 delims=\" %%A in ('whoami') Do (set computer=%%A & set User1=%%B)
    set MSDNme=%User1:~0,1%
    set LSDNme=%User1:~1,10%
    call :UpCase MSDNme
    set User=%MSDNme%%LSDNme%
    :
    rem                    (Date format = 06/08/2015)                     
    set CurDate=%DATE%
    rem          (Time format = (13:05:60:MS - 24 hour setting))       
    rem         Morning Hours have leading space vs leading zero.    
    set ActHR=%TIME:~0,2%
    if "%TIME:~0,1%"==" "  set ActHR=0%ActHR:~1,1%
    set CurTime=%ActHR%%TIME:~2,3%
    :
    rem                  Calculate the Run Julian Date                  
    set DSYr=%DATE:~6,4%
    set DSMth=%DATE:~0,2%
    set DSDay=%DATE:~3,2%
    call :CvtJulian %DSMth% %DSDay% %DSYr%
    set RunJDN=%JDN%
    :
    rem  The Script will utilize the keeping of the number of days of Quicken Data  
    rem  Backup Files as specified by the Retain Files Field shown below.          
    :
    rem  If the Retain Files Field has a Value of Zero (0), the Script will only    
    rem  display Statistics about the Files in the Directory. Otherwise, it will set
    rem  the "Retain Files" Interval by utilizing Julian Dates to convert the New  
    rem  Date Limit formatted YYYY-MM-DD in showing for Informational purposes only.
    rem   (The below Retain Files Field Value will keep two weeks of Quicken Data   
    rem    Backup Files in the Backup Directory; if no User Input via Command Line.)
    :
    rem              Accept any Incoming User Number of Files to Retain        
    if "%~1" lss "0"  (
                   set Dayts=14
               ) else (
                   set /a Dayts=%~1+0 )
    set RetainFiles=%Dayts%
    :
    set /a AdjJDN=%RunJDN%-%RetainFiles%+1
    call :CvtDate %AdjJDN%
    set CutDate=%yy%-%mm%-%dd%
    :
    rem   The Script will also utilize the keeping of the number of Files to View  
    rem   as specified by the Num of Fles Field shown below. If the User Input is   
    rem   found to be a zero (0), no listing of files will be initiated.       
    rem   ** Also currently the Script will only allow entries of 0 thru 9. due to  
    rem   ** the Creator's inexperienced in allowing two-digit numbers in the coded
    rem   ** dir commands.                                                          
    rem     (The below Number of Fles Field Value will list 5 Files in the Backup   
    rem      Directory; if no User Input via Command Line.)                         
    :
    rem                Accept any Incoming User Number of Files to List         
    if "%~2" equ ""  (
                   set Filets=5
              ) else (
                   set /a Filets=%~2+0 )
    set NumofFles=%Filets%
    if %NumofFles% gtr 9      set NumofFles=9
    :
    cls
    Echo(
    Echo                    Quicken Data File Clean-Up Utility
    Echo       %CurDate%                                        %CurTime%
    Echo(
    Echo                    ** Retrieving Backup Data Files. **
    :
    If %RetainFiles% equ 0        goto ShwDir
    :
    echo     You, %User%, have chosen to keep the latest %RetainFiles% Files in the Directory;
    echo     (%Bkupfolder%)
    echo --------------------------------------------------------------------------------
    goto Cont
    :
    :ShwDir rem  * Label ShwDir *
    echo --------------------------------------------------------------------------------
    echo     You, %User%, have chosen to keep your Data Files in the Directory;
    echo     (%Bkupfolder%)
    echo --------------------------------------------------------------------------------
    :
    :Cont rem                       * Label Cont *
    set BkupDrv=%Bkupfolder:~0,2%
    %BkupDrv%
    cd %Bkupfolder%
    :
    rem          Check to see if there are data files in the Directory
    set ctr=0
    for %%x in (*) do set /a ctr+=1
    If %ctr% neq 0                goto Cont1
    echo     NO Backup Data Files in Directory!!
    echo --------------------------------------------------------------------------------
    goto EndPrc
    :
    :Cont1 rem                        * Label Cont1 *
    If %RetainFiles% equ 0        goto ShwStat
    rem            Check No. of Files to see if there are more data files than needed
    If %ctr% leq %RetainFiles%    goto Cont2
    :
    echo     There are %ctr% data files in the Directory.
    echo --------------------------------------------------------------------------------
    echo     Any Backup Data File having a Modified Date previous to the one below shown
    echo                             will be deleted.
    echo                               (%CutDate%)
    echo     (The Above Modified Date will also match the Date found in the selected 
    echo      Backup Data File Names; since each Backup Data File was created (Modified) 
    echo      only ONCE).
    echo --------------------------------------------------------------------------------
    :
    forfiles /d -%RetainFiles% /c "cmd /c del /q @file">;nul
    rem          Retrieve the revised number of data files in the Directory.
    set ctr1=0
    for %%x in (*) do set /a ctr1+=1
    set /a DelCnt=%ctr%-%ctr1%
    echo     Number of Files deleted = %DelCnt%.
    echo --------------------------------------------------------------------------------
    set ctr=%ctr1%
    goto Cont3
    :
    :ShwStat rem                    * Label ShwStat *
    If %ctr% equ 1             goto Show     
    echo     There are %ctr% data files in the Directory.
    echo --------------------------------------------------------------------------------
    If %NumofFles% equ 0       goto EndPrc
    echo     Listing up to the first %NumofFles% newest entries in the Directory.
    echo --------------------------------------------------------------------------------
    dir /b /p /w /o-d|findstr/n ^^|findstr "^[1-%NumofFles%]:"
    echo --------------------------------------------------------------------------------
    goto Cont4
    :
    :Show rem                        * Label Show *
    echo     There is only %ctr% data file in the Directory.
    echo --------------------------------------------------------------------------------
    If %NumofFles% equ 0        goto EndPrc
    echo            Listing the only entry in the Directory.
    echo --------------------------------------------------------------------------------
    dir /b /p /w /o-d|findstr/n ^^|findstr "^[1-1]:"
    echo --------------------------------------------------------------------------------
    goto Cont4
    :
    :Cont2 rem                         * Label Cont2 *
    echo     Found no Backup Data Files exceeding the %RetainFiles%-File Limit to Delete.
    :
    :Cont3 rem                         * Label Cont3 *
    If %ctr% equ 1             goto Show1     
    echo     There are %ctr% data files in the Directory.
    echo --------------------------------------------------------------------------------
    :
    :Cont4 rem                          * Label Cont4 *
    If %NumofFles% equ 0        goto EndPrc
    echo     Listing up to the first %NumofFles% oldest entries in the Directory.
    echo --------------------------------------------------------------------------------
    dir /b /p /w /od|findstr/n ^^|findstr "^[1-%NumofFles%]:"
    echo --------------------------------------------------------------------------------
    goto EndPrc
    :
    :Show1 rem                           * Label Show1 *
    echo     There is only %ctr% data file in the Directory.
    echo --------------------------------------------------------------------------------
    If %NumofFles% equ 0        goto EndPrc
    echo            Listing the only entry in the Directory.
    echo --------------------------------------------------------------------------------
    dir /b /p /w /od|findstr/n ^^|findstr "^[1-1]:"
    echo --------------------------------------------------------------------------------
    :
    :EndPrc rem                         * Label EndPrc *
    pause
    endlocal
    color
    exit /b
    :
    rem                                 ** Subroutines **
    :
    :CvtJulian rem                      ** Subroutine CvtJulian **
    rem                             Convert Date to Julian Day Number                
    rem                          Retrieve Month, Day, and Year Values               
    rem                              (Date format = 06/08/2015)                         
    set mm=%1%
    set dd=%2%
    set yy=%3%
    rem                             Eliminate Left Zeros (dd & mm)                         
    set /a dd=10%dd% %% 100, mm=10%mm% %% 100
    rem                             Calculate Julian Day Number                   
    if %mm% lss 3     set /a mm+=12, yy-=1
    set /a A=yy/100, B=A/4, C=2-A+B, E=36525*(yy+4716)/100, F=306*(mm+1)/10
    set /a JDN=C+dd+E+F-1524
    exit /b
    :
    :CvtDate rem                          ** Subroutine CvtDate **
    rem                        Convert Julian Day Number to Month, Day, Year            
    rem                                  (Date format = 06/08/2015)                           
    set /a W=(%1*100-186721625)/3652425, X=W/4, A=%1+1+W-X, B=A+1524
    set /a C=(B*100-12210)/36525, D=36525*C/100, E=(B-D)*10000/306001, F=306001*E/10000
    set /a dd=B-D-F, mm=E-1, yy=C-4716
    if %mm% gtr 12      set /a mm-=12, yy+=1
    rem                     Insert Left Zeros, If needed                              
    if %dd% lss 10        set dd=0%dd%
    if %mm% lss 10      set mm=0%mm%
    exit /b
    :
    :UpCase rem                            ** Subroutine UpCase **
    rem                         Convert Lower Case Letters to Upper Case         
    for %%a in ("a=A" "b=B" "c=C" "d=D" "e=E" "f=F" "g=G" "h=H" "i=I"
                "j=J" "k=K" "l=L" "m=M" "n=N" "o=O" "p=P" "q=Q" "r=R"
                "s=S" "t=T" "u=U" "v=V" "w=W" "x=X" "y=Y" "z=Z") do call set "%1=%%%1:%%~a%%"
    exit /b
    Now running the 2019 Windows Subscription Plan
    Retired - former Computer System Analyst
  • ClaytonClayton Member
    edited May 2018
    Jerry said:







    Clayton Thanks for posting a batch script. I forgot about utilizing the colon (:) to show a blank line in a script. However, I do employ it on the Label lines. Go figure!! (LOL)

    Folks, with that in mind, I have resubmitted my script utilizing colon lines; made a correction to the script, and added personnel user data to the script.

    To all viewing this Post, feel free to copy it to your System to utilize and to enjoy.


    @Echo off

    color 4f
    rem color f0
    title Quicken Backup Data File Clean-Up Utility
    setlocal enableextensions
    :
    rem         Data File Utility in working with Quicken Data Backups
    rem       To be utilized with Windows 7 and above Operating Systems.             
    rem                   (Date format = (06/08/2015)                              
    rem             (Time format = (13:05 - 24 hour setting)                     
    rem           (Backup Drive = E - External Portable Drive)                   
    :
    rem        Please replace the following (SET) line with you own            
    rem                       Directory location                            
    set Bkupfolder=E:\Quicken Data Backups
    :
    rem      Retrieving Personal data of the User and Captializing
    rem      the First Letter of the Name
    for /f "tokens=1-2 delims=\" %%A in ('whoami') Do (set computer=%%A & set User1=%%B)
    set MSDNme=%User1:~0,1%
    set LSDNme=%User1:~1,10%
    call :UpCase MSDNme
    set User=%MSDNme%%LSDNme%
    :
    rem                    (Date format = 06/08/2015)                     
    set CurDate=%DATE%
    rem          (Time format = (13:05:60:MS - 24 hour setting))       
    rem         Morning Hours have leading space vs leading zero.    
    set ActHR=%TIME:~0,2%
    if "%TIME:~0,1%"==" "  set ActHR=0%ActHR:~1,1%
    set CurTime=%ActHR%%TIME:~2,3%
    :
    rem                  Calculate the Run Julian Date                  
    set DSYr=%DATE:~6,4%
    set DSMth=%DATE:~0,2%
    set DSDay=%DATE:~3,2%
    call :CvtJulian %DSMth% %DSDay% %DSYr%
    set RunJDN=%JDN%
    :
    rem  The Script will utilize the keeping of the number of days of Quicken Data  
    rem  Backup Files as specified by the Retain Files Field shown below.          
    :
    rem  If the Retain Files Field has a Value of Zero (0), the Script will only    
    rem  display Statistics about the Files in the Directory. Otherwise, it will set
    rem  the "Retain Files" Interval by utilizing Julian Dates to convert the New  
    rem  Date Limit formatted YYYY-MM-DD in showing for Informational purposes only.
    rem   (The below Retain Files Field Value will keep two weeks of Quicken Data   
    rem    Backup Files in the Backup Directory; if no User Input via Command Line.)
    :
    rem              Accept any Incoming User Number of Files to Retain        
    if "%~1" lss "0"  (
                   set Dayts=14
               ) else (
                   set /a Dayts=%~1+0 )
    set RetainFiles=%Dayts%
    :
    set /a AdjJDN=%RunJDN%-%RetainFiles%+1
    call :CvtDate %AdjJDN%
    set CutDate=%yy%-%mm%-%dd%
    :
    rem   The Script will also utilize the keeping of the number of Files to View  
    rem   as specified by the Num of Fles Field shown below. If the User Input is   
    rem   found to be a zero (0), no listing of files will be initiated.       
    rem   ** Also currently the Script will only allow entries of 0 thru 9. due to  
    rem   ** the Creator's inexperienced in allowing two-digit numbers in the coded
    rem   ** dir commands.                                                          
    rem     (The below Number of Fles Field Value will list 5 Files in the Backup   
    rem      Directory; if no User Input via Command Line.)                         
    :
    rem                Accept any Incoming User Number of Files to List         
    if "%~2" equ ""  (
                   set Filets=5
              ) else (
                   set /a Filets=%~2+0 )
    set NumofFles=%Filets%
    if %NumofFles% gtr 9      set NumofFles=9
    :
    cls
    Echo(
    Echo                    Quicken Data File Clean-Up Utility
    Echo       %CurDate%                                        %CurTime%
    Echo(
    Echo                    ** Retrieving Backup Data Files. **
    :
    If %RetainFiles% equ 0        goto ShwDir
    :
    echo     You, %User%, have chosen to keep the latest %RetainFiles% Files in the Directory;
    echo     (%Bkupfolder%)
    echo --------------------------------------------------------------------------------
    goto Cont
    :
    :ShwDir rem  * Label ShwDir *
    echo --------------------------------------------------------------------------------
    echo     You, %User%, have chosen to keep your Data Files in the Directory;
    echo     (%Bkupfolder%)
    echo --------------------------------------------------------------------------------
    :
    :Cont rem                       * Label Cont *
    set BkupDrv=%Bkupfolder:~0,2%
    %BkupDrv%
    cd %Bkupfolder%
    :
    rem          Check to see if there are data files in the Directory
    set ctr=0
    for %%x in (*) do set /a ctr+=1
    If %ctr% neq 0                goto Cont1
    echo     NO Backup Data Files in Directory!!
    echo --------------------------------------------------------------------------------
    goto EndPrc
    :
    :Cont1 rem                        * Label Cont1 *
    If %RetainFiles% equ 0        goto ShwStat
    rem            Check No. of Files to see if there are more data files than needed
    If %ctr% leq %RetainFiles%    goto Cont2
    :
    echo     There are %ctr% data files in the Directory.
    echo --------------------------------------------------------------------------------
    echo     Any Backup Data File having a Modified Date previous to the one below shown
    echo                             will be deleted.
    echo                               (%CutDate%)
    echo     (The Above Modified Date will also match the Date found in the selected 
    echo      Backup Data File Names; since each Backup Data File was created (Modified) 
    echo      only ONCE).
    echo --------------------------------------------------------------------------------
    :
    forfiles /d -%RetainFiles% /c "cmd /c del /q @file">;nul
    rem          Retrieve the revised number of data files in the Directory.
    set ctr1=0
    for %%x in (*) do set /a ctr1+=1
    set /a DelCnt=%ctr%-%ctr1%
    echo     Number of Files deleted = %DelCnt%.
    echo --------------------------------------------------------------------------------
    set ctr=%ctr1%
    goto Cont3
    :
    :ShwStat rem                    * Label ShwStat *
    If %ctr% equ 1             goto Show     
    echo     There are %ctr% data files in the Directory.
    echo --------------------------------------------------------------------------------
    If %NumofFles% equ 0       goto EndPrc
    echo     Listing up to the first %NumofFles% newest entries in the Directory.
    echo --------------------------------------------------------------------------------
    dir /b /p /w /o-d|findstr/n ^^|findstr "^[1-%NumofFles%]:"
    echo --------------------------------------------------------------------------------
    goto Cont4
    :
    :Show rem                        * Label Show *
    echo     There is only %ctr% data file in the Directory.
    echo --------------------------------------------------------------------------------
    If %NumofFles% equ 0        goto EndPrc
    echo            Listing the only entry in the Directory.
    echo --------------------------------------------------------------------------------
    dir /b /p /w /o-d|findstr/n ^^|findstr "^[1-1]:"
    echo --------------------------------------------------------------------------------
    goto Cont4
    :
    :Cont2 rem                         * Label Cont2 *
    echo     Found no Backup Data Files exceeding the %RetainFiles%-File Limit to Delete.
    :
    :Cont3 rem                         * Label Cont3 *
    If %ctr% equ 1             goto Show1     
    echo     There are %ctr% data files in the Directory.
    echo --------------------------------------------------------------------------------
    :
    :Cont4 rem                          * Label Cont4 *
    If %NumofFles% equ 0        goto EndPrc
    echo     Listing up to the first %NumofFles% oldest entries in the Directory.
    echo --------------------------------------------------------------------------------
    dir /b /p /w /od|findstr/n ^^|findstr "^[1-%NumofFles%]:"
    echo --------------------------------------------------------------------------------
    goto EndPrc
    :
    :Show1 rem                           * Label Show1 *
    echo     There is only %ctr% data file in the Directory.
    echo --------------------------------------------------------------------------------
    If %NumofFles% equ 0        goto EndPrc
    echo            Listing the only entry in the Directory.
    echo --------------------------------------------------------------------------------
    dir /b /p /w /od|findstr/n ^^|findstr "^[1-1]:"
    echo --------------------------------------------------------------------------------
    :
    :EndPrc rem                         * Label EndPrc *
    pause
    endlocal
    color
    exit /b
    :
    rem                                 ** Subroutines **
    :
    :CvtJulian rem                      ** Subroutine CvtJulian **
    rem                             Convert Date to Julian Day Number                
    rem                          Retrieve Month, Day, and Year Values               
    rem                              (Date format = 06/08/2015)                         
    set mm=%1%
    set dd=%2%
    set yy=%3%
    rem                             Eliminate Left Zeros (dd & mm)                         
    set /a dd=10%dd% %% 100, mm=10%mm% %% 100
    rem                             Calculate Julian Day Number                   
    if %mm% lss 3     set /a mm+=12, yy-=1
    set /a A=yy/100, B=A/4, C=2-A+B, E=36525*(yy+4716)/100, F=306*(mm+1)/10
    set /a JDN=C+dd+E+F-1524
    exit /b
    :
    :CvtDate rem                          ** Subroutine CvtDate **
    rem                        Convert Julian Day Number to Month, Day, Year            
    rem                                  (Date format = 06/08/2015)                           
    set /a W=(%1*100-186721625)/3652425, X=W/4, A=%1+1+W-X, B=A+1524
    set /a C=(B*100-12210)/36525, D=36525*C/100, E=(B-D)*10000/306001, F=306001*E/10000
    set /a dd=B-D-F, mm=E-1, yy=C-4716
    if %mm% gtr 12      set /a mm-=12, yy+=1
    rem                     Insert Left Zeros, If needed                              
    if %dd% lss 10        set dd=0%dd%
    if %mm% lss 10      set mm=0%mm%
    exit /b
    :
    :UpCase rem                            ** Subroutine UpCase **
    rem                         Convert Lower Case Letters to Upper Case         
    for %%a in ("a=A" "b=B" "c=C" "d=D" "e=E" "f=F" "g=G" "h=H" "i=I"
                "j=J" "k=K" "l=L" "m=M" "n=N" "o=O" "p=P" "q=Q" "r=R"
                "s=S" "t=T" "u=U" "v=V" "w=W" "x=X" "y=Y" "z=Z") do call set "%1=%%%1:%%~a%%"
    exit /b
    Hey, thanks for the revision. And yeah we do get in a rut with programing practices. I was only a moderate Batch File Artist and somewhat light weight AutoCAD LISP writer. After 10 years in retirement, I've forgotten a LOT.
  • Jerry_Jerry_ Member
    edited November 2018
    Clayton, here is an updated version of the Script. Now when you list the oldest or newest files in the Directory, each entry of the File will also show the date, time and size of the File. Update if you want.

    @Echo off
    color 4f
    rem color f0
    title Quicken Backup Data File Clean-Up Utility
    setlocal enableextensions
    :
    rem         Data File Utility in working with Quicken Data Backups
    rem       To be utilized with Windows 7 and above Operating Systems.             
    rem                   (Date format = (06/08/2015)                              
    rem             (Time format = (13:05 - 24 hour setting)                     
    rem           (Backup Drive = E - External Portable Drive)                   
    :
    rem        Please replace the following (SET) line with you own            
    rem                       Directory location                            
    set Bkupfolder=E:\Quicken Data Backups
    :
    rem      Retrieving Personal data of the User and Captializing
    rem      the First Letter of the Name
    for /f "tokens=1-2 delims=\" %%A in ('whoami') Do (set computer=%%A & set User1=%%B)
    set MSDNme=%User1:~0,1%
    set LSDNme=%User1:~1,10%
    call :UpCase MSDNme
    set User=%MSDNme%%LSDNme%
    :
    rem                    (Date format = 06/08/2015)                     
    set CurDate=%DATE%
    rem          (Time format = (13:05:60:MS - 24 hour setting))       
    rem         Morning Hours have leading space vs leading zero.    
    set ActHR=%TIME:~0,2%
    if "%TIME:~0,1%"==" "  set ActHR=0%ActHR:~1,1%
    set CurTime=%ActHR%%TIME:~2,3%
    :
    rem                  Calculate the Run Julian Date                  
    set DSYr=%DATE:~6,4%
    set DSMth=%DATE:~0,2%
    set DSDay=%DATE:~3,2%
    call :CvtJulian %DSMth% %DSDay% %DSYr%
    set RunJDN=%JDN%
    :
    rem  The Script will utilize the keeping of the number of days of Quicken Data  
    rem  Backup Files as specified by the Retain Files Field shown below.          
    :
    rem  If the Retain Files Field has a Value of Zero (0), the Script will only    
    rem  display Statistics about the Files in the Directory. Otherwise, it will set
    rem  the "Retain Files" Interval by utilizing Julian Dates to convert the New  
    rem  Date Limit formatted YYYY-MM-DD in showing for Informational purposes only.
    rem   (The below Retain Files Field Value will keep two weeks of Quicken Data   
    rem    Backup Files in the Backup Directory; if no User Input via Command Line.)
    :
    rem              Accept any Incoming User Number of Files to Retain        
    if "%~1" lss "0"  (
                   set Dayts=14
               ) else (
                   set /a Dayts=%~1+0 )
    set RetainFiles=%Dayts%
    :
    set /a AdjJDN=%RunJDN%-%RetainFiles%+1
    call :CvtDate %AdjJDN%
    set CutDate=%yy%-%mm%-%dd%
    :
    rem   The Script will also utilize the keeping of the number of Files to View  
    rem   as specified by the Num of Fles Field shown below. If the User Input is   
    rem   found to be a zero (0), no listing of files will be initiated.       
    rem   ** Also currently the Script will only allow entries of 0 thru 9. due to  
    rem   ** the Creator's inexperienced in allowing two-digit numbers in the coded
    rem   ** dir commands.                                                          
    rem     (The below Number of Fles Field Value will list 5 Files in the Backup   
    rem      Directory; if no User Input via Command Line.)                         
    :
    rem                Accept any Incoming User Number of Files to List         
    if "%~2" equ ""  (
                   set Filets=5
              ) else (
                   set /a Filets=%~2+0 )
    set NumofFles=%Filets%
    if %NumofFles% gtr 9      set NumofFles=9
    :
    cls
    Echo(
    Echo                    Quicken Data File Clean-Up Utility
    Echo       %CurDate%                                        %CurTime%
    Echo(
    Echo                    ** Retrieving Backup Data Files. **
    :
    If %RetainFiles% equ 0        goto ShwDir
    :
    echo     You, %User%, have chosen to keep the latest %RetainFiles% Files in the Directory;
    echo     (%Bkupfolder%)
    echo --------------------------------------------------------------------------------
    goto Cont
    :
    :ShwDir rem  * Label ShwDir *
    echo --------------------------------------------------------------------------------
    echo     You, %User%, have chosen to keep your Data Files in the Directory;
    echo     (%Bkupfolder%)
    echo --------------------------------------------------------------------------------
    :
    :Cont rem                       * Label Cont *
    set BkupDrv=%Bkupfolder:~0,2%
    %BkupDrv%
    cd %Bkupfolder%
    :
    rem          Check to see if there are data files in the Directory
    set ctr=0
    for %%x in (*) do set /a ctr+=1
    If %ctr% neq 0                goto Cont1
    echo     NO Backup Data Files in Directory!!
    echo --------------------------------------------------------------------------------
    goto EndPrc
    :
    :Cont1 rem                        * Label Cont1 *
    If %RetainFiles% equ 0        goto ShwStat
    rem            Check No. of Files to see if there are more data files than needed
    If %ctr% leq %RetainFiles%    goto Cont2
    :
    echo     There are %ctr% data files in the Directory.
    echo --------------------------------------------------------------------------------
    echo     Any Backup Data File having a Modified Date previous to the one below shown
    echo                             will be deleted.
    echo                               (%CutDate%)
    echo     (The Above Modified Date will also match the Date found in the selected 
    echo      Backup Data File Names; since each Backup Data File was created (Modified) 
    echo      only ONCE).
    echo --------------------------------------------------------------------------------
    :
    forfiles /d -%RetainFiles% /c "cmd /c del /q @file">;nul
    rem          Retrieve the revised number of data files in the Directory.
    set ctr1=0
    for %%x in (*) do set /a ctr1+=1
    set /a DelCnt=%ctr%-%ctr1%
    echo     Number of Files deleted = %DelCnt%.
    echo --------------------------------------------------------------------------------
    set ctr=%ctr1%
    goto Cont3
    :
    :ShwStat rem                    * Label ShwStat *
    If %ctr% equ 1             goto Show     
    echo     There are %ctr% data files in the Directory.
    echo --------------------------------------------------------------------------------
    If %NumofFles% equ 0       goto EndPrc
    echo     Listing up to the first %NumofFles% newest entries in the Directory.
    echo --------------------------------------------------------------------------------
    dir /p /o:-d|find "QDF"|findstr/n ^^|findstr "^[1-%Numoffles%]:"
    echo --------------------------------------------------------------------------------
    goto Cont4
    :
    :Show rem                        * Label Show *
    echo     There is only %ctr% data file in the Directory.
    echo --------------------------------------------------------------------------------
    If %NumofFles% equ 0        goto EndPrc
    echo            Listing the only entry in the Directory.
    echo --------------------------------------------------------------------------------
    dir /p /o:-d|find "QDF"|findstr/n ^^|findstr "^[1-1]:"
    echo --------------------------------------------------------------------------------
    goto Cont4
    :
    :Cont2 rem                         * Label Cont2 *
    echo     Found no Backup Data Files exceeding the %RetainFiles%-File Limit to Delete.
    :
    :Cont3 rem                         * Label Cont3 *
    If %ctr% equ 1             goto Show1     
    echo     There are %ctr% data files in the Directory.
    echo --------------------------------------------------------------------------------
    :
    :Cont4 rem                          * Label Cont4 *
    If %NumofFles% equ 0        goto EndPrc
    echo     Listing up to the first %NumofFles% oldest entries in the Directory.
    echo --------------------------------------------------------------------------------
    dir /p /o:d|find "QDF"|findstr/n ^^|findstr "^[1-%Numoffles%]:"
    echo --------------------------------------------------------------------------------
    goto EndPrc
    :
    :Show1 rem                           * Label Show1 *
    echo     There is only %ctr% data file in the Directory.
    echo --------------------------------------------------------------------------------
    If %NumofFles% equ 0        goto EndPrc
    echo            Listing the only entry in the Directory.
    echo --------------------------------------------------------------------------------
    dir /p /o:d|find "QDF"|findstr/n ^^|findstr "^[1-1]:"
    echo --------------------------------------------------------------------------------
    :
    :EndPrc rem                         * Label EndPrc *
    pause
    endlocal
    color
    exit /b
    :
    rem                                 ** Subroutines **
    :
    :CvtJulian rem                      ** Subroutine CvtJulian **
    rem                             Convert Date to Julian Day Number                
    rem                          Retrieve Month, Day, and Year Values               
    rem                              (Date format = 06/08/2015)                         
    set mm=%1%
    set dd=%2%
    set yy=%3%
    rem                             Eliminate Left Zeros (dd & mm)                         
    set /a dd=10%dd% %% 100, mm=10%mm% %% 100
    rem                             Calculate Julian Day Number                   
    if %mm% lss 3     set /a mm+=12, yy-=1
    set /a A=yy/100, B=A/4, C=2-A+B, E=36525*(yy+4716)/100, F=306*(mm+1)/10
    set /a JDN=C+dd+E+F-1524
    exit /b
    :
    :CvtDate rem                          ** Subroutine CvtDate **
    rem                        Convert Julian Day Number to Month, Day, Year            
    rem                                  (Date format = 06/08/2015)                           
    set /a W=(%1*100-186721625)/3652425, X=W/4, A=%1+1+W-X, B=A+1524
    set /a C=(B*100-12210)/36525, D=36525*C/100, E=(B-D)*10000/306001, F=306001*E/10000
    set /a dd=B-D-F, mm=E-1, yy=C-4716
    if %mm% gtr 12      set /a mm-=12, yy+=1
    rem                     Insert Left Zeros, If needed                              
    if %dd% lss 10        set dd=0%dd%
    if %mm% lss 10      set mm=0%mm%
    exit /b
    :
    :UpCase rem                            ** Subroutine UpCase **
    rem                         Convert Lower Case Letters to Upper Case         
    for %%a in ("a=A" "b=B" "c=C" "d=D" "e=E" "f=F" "g=G" "h=H" "i=I"
                "j=J" "k=K" "l=L" "m=M" "n=N" "o=O" "p=P" "q=Q" "r=R"
                "s=S" "t=T" "u=U" "v=V" "w=W" "x=X" "y=Y" "z=Z") do call set "%1=%%%1:%%~a%%"
    exit /b
    Now running the 2019 Windows Subscription Plan
    Retired - former Computer System Analyst
  • ClaytonClayton Member
    edited May 2018
    Jerry said:

    Clayton, here is an updated version of the Script. Now when you list the oldest or newest files in the Directory, each entry of the File will also show the date, time and size of the File. Update if you want.

    @Echo off
    color 4f
    rem color f0
    title Quicken Backup Data File Clean-Up Utility
    setlocal enableextensions
    :
    rem         Data File Utility in working with Quicken Data Backups
    rem       To be utilized with Windows 7 and above Operating Systems.             
    rem                   (Date format = (06/08/2015)                              
    rem             (Time format = (13:05 - 24 hour setting)                     
    rem           (Backup Drive = E - External Portable Drive)                   
    :
    rem        Please replace the following (SET) line with you own            
    rem                       Directory location                            
    set Bkupfolder=E:\Quicken Data Backups
    :
    rem      Retrieving Personal data of the User and Captializing
    rem      the First Letter of the Name
    for /f "tokens=1-2 delims=\" %%A in ('whoami') Do (set computer=%%A & set User1=%%B)
    set MSDNme=%User1:~0,1%
    set LSDNme=%User1:~1,10%
    call :UpCase MSDNme
    set User=%MSDNme%%LSDNme%
    :
    rem                    (Date format = 06/08/2015)                     
    set CurDate=%DATE%
    rem          (Time format = (13:05:60:MS - 24 hour setting))       
    rem         Morning Hours have leading space vs leading zero.    
    set ActHR=%TIME:~0,2%
    if "%TIME:~0,1%"==" "  set ActHR=0%ActHR:~1,1%
    set CurTime=%ActHR%%TIME:~2,3%
    :
    rem                  Calculate the Run Julian Date                  
    set DSYr=%DATE:~6,4%
    set DSMth=%DATE:~0,2%
    set DSDay=%DATE:~3,2%
    call :CvtJulian %DSMth% %DSDay% %DSYr%
    set RunJDN=%JDN%
    :
    rem  The Script will utilize the keeping of the number of days of Quicken Data  
    rem  Backup Files as specified by the Retain Files Field shown below.          
    :
    rem  If the Retain Files Field has a Value of Zero (0), the Script will only    
    rem  display Statistics about the Files in the Directory. Otherwise, it will set
    rem  the "Retain Files" Interval by utilizing Julian Dates to convert the New  
    rem  Date Limit formatted YYYY-MM-DD in showing for Informational purposes only.
    rem   (The below Retain Files Field Value will keep two weeks of Quicken Data   
    rem    Backup Files in the Backup Directory; if no User Input via Command Line.)
    :
    rem              Accept any Incoming User Number of Files to Retain        
    if "%~1" lss "0"  (
                   set Dayts=14
               ) else (
                   set /a Dayts=%~1+0 )
    set RetainFiles=%Dayts%
    :
    set /a AdjJDN=%RunJDN%-%RetainFiles%+1
    call :CvtDate %AdjJDN%
    set CutDate=%yy%-%mm%-%dd%
    :
    rem   The Script will also utilize the keeping of the number of Files to View  
    rem   as specified by the Num of Fles Field shown below. If the User Input is   
    rem   found to be a zero (0), no listing of files will be initiated.       
    rem   ** Also currently the Script will only allow entries of 0 thru 9. due to  
    rem   ** the Creator's inexperienced in allowing two-digit numbers in the coded
    rem   ** dir commands.                                                          
    rem     (The below Number of Fles Field Value will list 5 Files in the Backup   
    rem      Directory; if no User Input via Command Line.)                         
    :
    rem                Accept any Incoming User Number of Files to List         
    if "%~2" equ ""  (
                   set Filets=5
              ) else (
                   set /a Filets=%~2+0 )
    set NumofFles=%Filets%
    if %NumofFles% gtr 9      set NumofFles=9
    :
    cls
    Echo(
    Echo                    Quicken Data File Clean-Up Utility
    Echo       %CurDate%                                        %CurTime%
    Echo(
    Echo                    ** Retrieving Backup Data Files. **
    :
    If %RetainFiles% equ 0        goto ShwDir
    :
    echo     You, %User%, have chosen to keep the latest %RetainFiles% Files in the Directory;
    echo     (%Bkupfolder%)
    echo --------------------------------------------------------------------------------
    goto Cont
    :
    :ShwDir rem  * Label ShwDir *
    echo --------------------------------------------------------------------------------
    echo     You, %User%, have chosen to keep your Data Files in the Directory;
    echo     (%Bkupfolder%)
    echo --------------------------------------------------------------------------------
    :
    :Cont rem                       * Label Cont *
    set BkupDrv=%Bkupfolder:~0,2%
    %BkupDrv%
    cd %Bkupfolder%
    :
    rem          Check to see if there are data files in the Directory
    set ctr=0
    for %%x in (*) do set /a ctr+=1
    If %ctr% neq 0                goto Cont1
    echo     NO Backup Data Files in Directory!!
    echo --------------------------------------------------------------------------------
    goto EndPrc
    :
    :Cont1 rem                        * Label Cont1 *
    If %RetainFiles% equ 0        goto ShwStat
    rem            Check No. of Files to see if there are more data files than needed
    If %ctr% leq %RetainFiles%    goto Cont2
    :
    echo     There are %ctr% data files in the Directory.
    echo --------------------------------------------------------------------------------
    echo     Any Backup Data File having a Modified Date previous to the one below shown
    echo                             will be deleted.
    echo                               (%CutDate%)
    echo     (The Above Modified Date will also match the Date found in the selected 
    echo      Backup Data File Names; since each Backup Data File was created (Modified) 
    echo      only ONCE).
    echo --------------------------------------------------------------------------------
    :
    forfiles /d -%RetainFiles% /c "cmd /c del /q @file">;nul
    rem          Retrieve the revised number of data files in the Directory.
    set ctr1=0
    for %%x in (*) do set /a ctr1+=1
    set /a DelCnt=%ctr%-%ctr1%
    echo     Number of Files deleted = %DelCnt%.
    echo --------------------------------------------------------------------------------
    set ctr=%ctr1%
    goto Cont3
    :
    :ShwStat rem                    * Label ShwStat *
    If %ctr% equ 1             goto Show     
    echo     There are %ctr% data files in the Directory.
    echo --------------------------------------------------------------------------------
    If %NumofFles% equ 0       goto EndPrc
    echo     Listing up to the first %NumofFles% newest entries in the Directory.
    echo --------------------------------------------------------------------------------
    dir /p /o:-d|find "QDF"|findstr/n ^^|findstr "^[1-%Numoffles%]:"
    echo --------------------------------------------------------------------------------
    goto Cont4
    :
    :Show rem                        * Label Show *
    echo     There is only %ctr% data file in the Directory.
    echo --------------------------------------------------------------------------------
    If %NumofFles% equ 0        goto EndPrc
    echo            Listing the only entry in the Directory.
    echo --------------------------------------------------------------------------------
    dir /p /o:-d|find "QDF"|findstr/n ^^|findstr "^[1-1]:"
    echo --------------------------------------------------------------------------------
    goto Cont4
    :
    :Cont2 rem                         * Label Cont2 *
    echo     Found no Backup Data Files exceeding the %RetainFiles%-File Limit to Delete.
    :
    :Cont3 rem                         * Label Cont3 *
    If %ctr% equ 1             goto Show1     
    echo     There are %ctr% data files in the Directory.
    echo --------------------------------------------------------------------------------
    :
    :Cont4 rem                          * Label Cont4 *
    If %NumofFles% equ 0        goto EndPrc
    echo     Listing up to the first %NumofFles% oldest entries in the Directory.
    echo --------------------------------------------------------------------------------
    dir /p /o:d|find "QDF"|findstr/n ^^|findstr "^[1-%Numoffles%]:"
    echo --------------------------------------------------------------------------------
    goto EndPrc
    :
    :Show1 rem                           * Label Show1 *
    echo     There is only %ctr% data file in the Directory.
    echo --------------------------------------------------------------------------------
    If %NumofFles% equ 0        goto EndPrc
    echo            Listing the only entry in the Directory.
    echo --------------------------------------------------------------------------------
    dir /p /o:d|find "QDF"|findstr/n ^^|findstr "^[1-1]:"
    echo --------------------------------------------------------------------------------
    :
    :EndPrc rem                         * Label EndPrc *
    pause
    endlocal
    color
    exit /b
    :
    rem                                 ** Subroutines **
    :
    :CvtJulian rem                      ** Subroutine CvtJulian **
    rem                             Convert Date to Julian Day Number                
    rem                          Retrieve Month, Day, and Year Values               
    rem                              (Date format = 06/08/2015)                         
    set mm=%1%
    set dd=%2%
    set yy=%3%
    rem                             Eliminate Left Zeros (dd & mm)                         
    set /a dd=10%dd% %% 100, mm=10%mm% %% 100
    rem                             Calculate Julian Day Number                   
    if %mm% lss 3     set /a mm+=12, yy-=1
    set /a A=yy/100, B=A/4, C=2-A+B, E=36525*(yy+4716)/100, F=306*(mm+1)/10
    set /a JDN=C+dd+E+F-1524
    exit /b
    :
    :CvtDate rem                          ** Subroutine CvtDate **
    rem                        Convert Julian Day Number to Month, Day, Year            
    rem                                  (Date format = 06/08/2015)                           
    set /a W=(%1*100-186721625)/3652425, X=W/4, A=%1+1+W-X, B=A+1524
    set /a C=(B*100-12210)/36525, D=36525*C/100, E=(B-D)*10000/306001, F=306001*E/10000
    set /a dd=B-D-F, mm=E-1, yy=C-4716
    if %mm% gtr 12      set /a mm-=12, yy+=1
    rem                     Insert Left Zeros, If needed                              
    if %dd% lss 10        set dd=0%dd%
    if %mm% lss 10      set mm=0%mm%
    exit /b
    :
    :UpCase rem                            ** Subroutine UpCase **
    rem                         Convert Lower Case Letters to Upper Case         
    for %%a in ("a=A" "b=B" "c=C" "d=D" "e=E" "f=F" "g=G" "h=H" "i=I"
                "j=J" "k=K" "l=L" "m=M" "n=N" "o=O" "p=P" "q=Q" "r=R"
                "s=S" "t=T" "u=U" "v=V" "w=W" "x=X" "y=Y" "z=Z") do call set "%1=%%%1:%%~a%%"
    exit /b

    Jerry
      .All along you probably thought your cleanup utility was a done deal. But it seems to have turned into a Work In Progress.
  • Jerry_Jerry_ Member
    edited May 2018
    Jerry said:

    Clayton, here is an updated version of the Script. Now when you list the oldest or newest files in the Directory, each entry of the File will also show the date, time and size of the File. Update if you want.

    @Echo off
    color 4f
    rem color f0
    title Quicken Backup Data File Clean-Up Utility
    setlocal enableextensions
    :
    rem         Data File Utility in working with Quicken Data Backups
    rem       To be utilized with Windows 7 and above Operating Systems.             
    rem                   (Date format = (06/08/2015)                              
    rem             (Time format = (13:05 - 24 hour setting)                     
    rem           (Backup Drive = E - External Portable Drive)                   
    :
    rem        Please replace the following (SET) line with you own            
    rem                       Directory location                            
    set Bkupfolder=E:\Quicken Data Backups
    :
    rem      Retrieving Personal data of the User and Captializing
    rem      the First Letter of the Name
    for /f "tokens=1-2 delims=\" %%A in ('whoami') Do (set computer=%%A & set User1=%%B)
    set MSDNme=%User1:~0,1%
    set LSDNme=%User1:~1,10%
    call :UpCase MSDNme
    set User=%MSDNme%%LSDNme%
    :
    rem                    (Date format = 06/08/2015)                     
    set CurDate=%DATE%
    rem          (Time format = (13:05:60:MS - 24 hour setting))       
    rem         Morning Hours have leading space vs leading zero.    
    set ActHR=%TIME:~0,2%
    if "%TIME:~0,1%"==" "  set ActHR=0%ActHR:~1,1%
    set CurTime=%ActHR%%TIME:~2,3%
    :
    rem                  Calculate the Run Julian Date                  
    set DSYr=%DATE:~6,4%
    set DSMth=%DATE:~0,2%
    set DSDay=%DATE:~3,2%
    call :CvtJulian %DSMth% %DSDay% %DSYr%
    set RunJDN=%JDN%
    :
    rem  The Script will utilize the keeping of the number of days of Quicken Data  
    rem  Backup Files as specified by the Retain Files Field shown below.          
    :
    rem  If the Retain Files Field has a Value of Zero (0), the Script will only    
    rem  display Statistics about the Files in the Directory. Otherwise, it will set
    rem  the "Retain Files" Interval by utilizing Julian Dates to convert the New  
    rem  Date Limit formatted YYYY-MM-DD in showing for Informational purposes only.
    rem   (The below Retain Files Field Value will keep two weeks of Quicken Data   
    rem    Backup Files in the Backup Directory; if no User Input via Command Line.)
    :
    rem              Accept any Incoming User Number of Files to Retain        
    if "%~1" lss "0"  (
                   set Dayts=14
               ) else (
                   set /a Dayts=%~1+0 )
    set RetainFiles=%Dayts%
    :
    set /a AdjJDN=%RunJDN%-%RetainFiles%+1
    call :CvtDate %AdjJDN%
    set CutDate=%yy%-%mm%-%dd%
    :
    rem   The Script will also utilize the keeping of the number of Files to View  
    rem   as specified by the Num of Fles Field shown below. If the User Input is   
    rem   found to be a zero (0), no listing of files will be initiated.       
    rem   ** Also currently the Script will only allow entries of 0 thru 9. due to  
    rem   ** the Creator's inexperienced in allowing two-digit numbers in the coded
    rem   ** dir commands.                                                          
    rem     (The below Number of Fles Field Value will list 5 Files in the Backup   
    rem      Directory; if no User Input via Command Line.)                         
    :
    rem                Accept any Incoming User Number of Files to List         
    if "%~2" equ ""  (
                   set Filets=5
              ) else (
                   set /a Filets=%~2+0 )
    set NumofFles=%Filets%
    if %NumofFles% gtr 9      set NumofFles=9
    :
    cls
    Echo(
    Echo                    Quicken Data File Clean-Up Utility
    Echo       %CurDate%                                        %CurTime%
    Echo(
    Echo                    ** Retrieving Backup Data Files. **
    :
    If %RetainFiles% equ 0        goto ShwDir
    :
    echo     You, %User%, have chosen to keep the latest %RetainFiles% Files in the Directory;
    echo     (%Bkupfolder%)
    echo --------------------------------------------------------------------------------
    goto Cont
    :
    :ShwDir rem  * Label ShwDir *
    echo --------------------------------------------------------------------------------
    echo     You, %User%, have chosen to keep your Data Files in the Directory;
    echo     (%Bkupfolder%)
    echo --------------------------------------------------------------------------------
    :
    :Cont rem                       * Label Cont *
    set BkupDrv=%Bkupfolder:~0,2%
    %BkupDrv%
    cd %Bkupfolder%
    :
    rem          Check to see if there are data files in the Directory
    set ctr=0
    for %%x in (*) do set /a ctr+=1
    If %ctr% neq 0                goto Cont1
    echo     NO Backup Data Files in Directory!!
    echo --------------------------------------------------------------------------------
    goto EndPrc
    :
    :Cont1 rem                        * Label Cont1 *
    If %RetainFiles% equ 0        goto ShwStat
    rem            Check No. of Files to see if there are more data files than needed
    If %ctr% leq %RetainFiles%    goto Cont2
    :
    echo     There are %ctr% data files in the Directory.
    echo --------------------------------------------------------------------------------
    echo     Any Backup Data File having a Modified Date previous to the one below shown
    echo                             will be deleted.
    echo                               (%CutDate%)
    echo     (The Above Modified Date will also match the Date found in the selected 
    echo      Backup Data File Names; since each Backup Data File was created (Modified) 
    echo      only ONCE).
    echo --------------------------------------------------------------------------------
    :
    forfiles /d -%RetainFiles% /c "cmd /c del /q @file">;nul
    rem          Retrieve the revised number of data files in the Directory.
    set ctr1=0
    for %%x in (*) do set /a ctr1+=1
    set /a DelCnt=%ctr%-%ctr1%
    echo     Number of Files deleted = %DelCnt%.
    echo --------------------------------------------------------------------------------
    set ctr=%ctr1%
    goto Cont3
    :
    :ShwStat rem                    * Label ShwStat *
    If %ctr% equ 1             goto Show     
    echo     There are %ctr% data files in the Directory.
    echo --------------------------------------------------------------------------------
    If %NumofFles% equ 0       goto EndPrc
    echo     Listing up to the first %NumofFles% newest entries in the Directory.
    echo --------------------------------------------------------------------------------
    dir /p /o:-d|find "QDF"|findstr/n ^^|findstr "^[1-%Numoffles%]:"
    echo --------------------------------------------------------------------------------
    goto Cont4
    :
    :Show rem                        * Label Show *
    echo     There is only %ctr% data file in the Directory.
    echo --------------------------------------------------------------------------------
    If %NumofFles% equ 0        goto EndPrc
    echo            Listing the only entry in the Directory.
    echo --------------------------------------------------------------------------------
    dir /p /o:-d|find "QDF"|findstr/n ^^|findstr "^[1-1]:"
    echo --------------------------------------------------------------------------------
    goto Cont4
    :
    :Cont2 rem                         * Label Cont2 *
    echo     Found no Backup Data Files exceeding the %RetainFiles%-File Limit to Delete.
    :
    :Cont3 rem                         * Label Cont3 *
    If %ctr% equ 1             goto Show1     
    echo     There are %ctr% data files in the Directory.
    echo --------------------------------------------------------------------------------
    :
    :Cont4 rem                          * Label Cont4 *
    If %NumofFles% equ 0        goto EndPrc
    echo     Listing up to the first %NumofFles% oldest entries in the Directory.
    echo --------------------------------------------------------------------------------
    dir /p /o:d|find "QDF"|findstr/n ^^|findstr "^[1-%Numoffles%]:"
    echo --------------------------------------------------------------------------------
    goto EndPrc
    :
    :Show1 rem                           * Label Show1 *
    echo     There is only %ctr% data file in the Directory.
    echo --------------------------------------------------------------------------------
    If %NumofFles% equ 0        goto EndPrc
    echo            Listing the only entry in the Directory.
    echo --------------------------------------------------------------------------------
    dir /p /o:d|find "QDF"|findstr/n ^^|findstr "^[1-1]:"
    echo --------------------------------------------------------------------------------
    :
    :EndPrc rem                         * Label EndPrc *
    pause
    endlocal
    color
    exit /b
    :
    rem                                 ** Subroutines **
    :
    :CvtJulian rem                      ** Subroutine CvtJulian **
    rem                             Convert Date to Julian Day Number                
    rem                          Retrieve Month, Day, and Year Values               
    rem                              (Date format = 06/08/2015)                         
    set mm=%1%
    set dd=%2%
    set yy=%3%
    rem                             Eliminate Left Zeros (dd & mm)                         
    set /a dd=10%dd% %% 100, mm=10%mm% %% 100
    rem                             Calculate Julian Day Number                   
    if %mm% lss 3     set /a mm+=12, yy-=1
    set /a A=yy/100, B=A/4, C=2-A+B, E=36525*(yy+4716)/100, F=306*(mm+1)/10
    set /a JDN=C+dd+E+F-1524
    exit /b
    :
    :CvtDate rem                          ** Subroutine CvtDate **
    rem                        Convert Julian Day Number to Month, Day, Year            
    rem                                  (Date format = 06/08/2015)                           
    set /a W=(%1*100-186721625)/3652425, X=W/4, A=%1+1+W-X, B=A+1524
    set /a C=(B*100-12210)/36525, D=36525*C/100, E=(B-D)*10000/306001, F=306001*E/10000
    set /a dd=B-D-F, mm=E-1, yy=C-4716
    if %mm% gtr 12      set /a mm-=12, yy+=1
    rem                     Insert Left Zeros, If needed                              
    if %dd% lss 10        set dd=0%dd%
    if %mm% lss 10      set mm=0%mm%
    exit /b
    :
    :UpCase rem                            ** Subroutine UpCase **
    rem                         Convert Lower Case Letters to Upper Case         
    for %%a in ("a=A" "b=B" "c=C" "d=D" "e=E" "f=F" "g=G" "h=H" "i=I"
                "j=J" "k=K" "l=L" "m=M" "n=N" "o=O" "p=P" "q=Q" "r=R"
                "s=S" "t=T" "u=U" "v=V" "w=W" "x=X" "y=Y" "z=Z") do call set "%1=%%%1:%%~a%%"
    exit /b

    As far as I know, it is now a finished product; unless I receive ideas for any updates. (grin)
    Now running the 2019 Windows Subscription Plan
    Retired - former Computer System Analyst
Sign In or Register to comment.