Skip to content

Archival Find script - Allows searching for files older/newer than a certain timeframe, with a minimum amount of files to be excluded/included.

Notifications You must be signed in to change notification settings

DanStaal/Arcfind

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

NAME
    arcfind - The archival file finder.

SYNOPSIS
    Usage: arcfind [opts] [dir]

    Options:

        --directory $DIR        The directory to work in.
    
        --files $MINFILES       The minimum number of files to leave behind.
        --minfiles $MINFILES
    
        --age $MAXAGE           The max age of the files to leave behind.
        --maxage $MAXAGE
    
        --longnames             Output full pathnames always.
    
        --shortnames            Output only the filename.
                                (No path component.)
    
        --inverse               Give the inverse output.
        --head
    
        --sort                  Give the output sorted by file age.
    
        --help                  Print a help message.
        --?

    All options can be shortened to the shortest unique string.

DESCRIPTION
    Arcfind is a program designed to help writing archive scripts. Given a
    directory $DIR, a max age of the files to keep $MAXAGE, and the minimum
    number of files to keep $MINFILES it returns a list of all the files in
    $DIR older than $MAXAGE, excluding at least $MINFILES. Files will not be
    listed if they are younger than $MAXAGE or if listing them would leave
    less than $MINFILES in the unlisted files.

    This program will *always* exclude at least $MINFILES, but *may* exclude
    more, if there are a lot of files younger than $MAXAGE.

  OPTIONS
    --directory $DIR

    Sets the directory to list files from. This will be read from the
    command line if the option is omitted, or will be set to the current
    working directory if not given.

    --files $MINFILES, --minfiles $MINFILES

    Sets the minimum number of files to *not* list. The default is 100.
    Setting this option without listing a number will set the default.
    Setting this to 0 gives the same output as: "find $DIR -mtime +MAXAGE
    -print"

    --age $MAXAGE, --maxage $MAXAGE

    Sets the maximum age of files to *not* list (in days). The default is 7
    days. Setting this option without listing a number will set the default.
    Setting this to 0 gives the same output as: "ls -t $DIR | tail
    +$MINFILES"

    --longnames

    Always use the full pathname to the files listed. The default is to use
    the full pathname if $DIR is not the current working directory, and the
    base filename if we are listing files in the current directory. This
    option overrides that so that even files in the current directory have
    the directory appended. This option can be unset with --nolongnames,
    which just sets the default action, and is overridden by --shortnames.

    Note that --nolongnames and --shortnames are not quite opposites: The
    first will list full pathnames outside of the current directory while
    the second won't. See --shortnames.

    --shortnames

    Always use just the basename when listing files. The default is to list
    the full pathname if we are not listing the current directory. With this
    option set the program will list only the filename, ignoring the
    directory component. This option can be unset with --noshortnames, which
    resets the default action.

    Note that --noshortnames and --longnames are not quite opposites: The
    first will list 'shortnames' in the current directory while the second
    won't. See --longnames.

    --inverse

    Invert the output: list every file that would *not* be listed in the
    normal output. This means that all files younger than $MAXAGE will be
    listed, with a minimum of $MINFILES in the listing. (Some of which could
    be older than $MAXAGE.)

    --sort

    Sort the output: Files will be listed oldest to newest. Note that output
    *may* be sorted without this option, but it is not *required* to be. If
    you want to rely on the sorting behavior, set this to be sure.

USAGE NOTES
    Example useage:

    "mv `arcfind` ../archive/"

    Move all files older than one week from the current folder to a folder
    named archive, leaving at least 100 files in the current folder.

    "arcfind -f 10 -a 5 -d /etc -i"

    List the ten most recently modified configuration files, or all
    configuration files that have been modified in the last five days.

REQUIREMENTS
    Perl. Preferably version 5.6.0 or greater.

    Uses the following Perl modules, some of which are installed by default:
    Cwd, Getopt::Long, File::Basename, File::Spec, Pod::Usage.

BUGS
    None known. Infinite unknown.

AUTHOR
    Version 1.1 written by Daniel T. Staal. Comments, bug reports, love
    letters, etc. should be sent to: DStaal@usa.net

COPYRIGHT
    Copyright 2008, Daniel T. Staal. All Rights Reserved.

    This is free software. You may copy or redistribute it under the same
    terms as Perl itself.

    This copyright will expire 5 years after the author's death, or in 30
    years, whichever is longer, unless such a period is in excess of local
    copyright law. After that this program is considered to be in the public
    domain.

About

Archival Find script - Allows searching for files older/newer than a certain timeframe, with a minimum amount of files to be excluded/included.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages