Remove excess log files past data mark

I have got application log files collecting up fast inside of a directory.

The logs contains many logs that look like this (were talking 1000s+):
the Log_NAME followed by Date and application specific nonsense.

(...)
application_log_2014-07-13_20-30-09 
application_log_2014-07-20_08-30-27 
(...)

Below is an excerpt of a script I use to backup excess log files before I remove all, I was wondering if anyone had any idea how I could create a script within this where I remove all scripts for last month. I think it should be possible to safely remove all the: application_log_*.... that are say older then $DT_limit I set. However I need expert opinion on this because I can not exceed the limit I set and need to be safe as folder contains other .ini and log files that must be ignored so care is needed.

##LOG FILE LOCATIONS##
##LOG FILE LOCATIONS##
##LOG FILE LOCATIONS##
export EXCESS_LOG_LOCATION="/excess_log/location"
export BACKUPDIR="/backup/log_backup"
export LOGFILE_LOCATION="/log_location"
 
## Date/Time variables

DT=`date '+%F:%H:%M'`


for file in `ls $EXCESS_LOG_LOCATION/application_log_*`
do
  mv ${file} ${BACKUPDIR}
  echo "log processed file ${file}" >> ${LOGFILE_LOCATION}
done
 
exit 0

I will post a script I am thinking of using as soon as I make progress but if anyone has an idea or has done this before let me know.

FYI - Ignore the Backup AND MV command functionality please this is just to help you see the logic I want to follow. and help you understand where I am trying to place the date check*.

What operating system are you on, as many date manipulation operations can be OS specific?

Do you have a date command that supports the --date option?

$ date --date "-10 days" +'%Y/%m/%d'
2014/08/02

I ran your command and it is supported. Ie I get the same result.

Rhel5

I think something like this should get the job done:

#!/bin/bash
LDATE=$(date --date "-$DT_limit days" +'%Y-%m-%d')

for file in $EXCESS_LOG_LOCATION/application_log_*
do
    FDATE=${file#*application_log_}
    FDATE=${FDATE%%_*}
    if [[ "$FDATE" < "$LDATE" ]] 
    then
        echo "file: $file is older than $DT_limit days"
    fi
done

Hey , Thanks for the help.
I really appreciate it!