NAME

CTK::Plugin::File - File plugin

VERSION

Version 1.00

SYNOPSIS

    use CTK;
    my $ctk = new CTK(
            plugins => "file",
        );

    my $n = $ctk->fcopy(
        -dirsrc => "/path/to/source/dir", # Source directory
        -dirdst => "/path/to/destination/dir", # Destination directory
        -glob   => "*.conf",
        -format => '[FILE].copy', # Format. Default: [FILE]
    );

    my $n = $ctk->fmove(
        -dirsrc => "/path/to/source/dir", # Source directory
        -dirdst => "/path/to/destination/dir", # Destination directory
        -glob   => "*.conf",
        -format => '[FILE]', # Format. Default: [FILE]
    );

    my $n = $ctk->fremove(
        -dirsrc => "/path/to/source/dir", # Source directory
        -glob   => "*.conf",
    );

    my $n = $ctk->fremove(
        -dirsrc => "/path/to/source/dir", # Source directory
        -glob   => "*.conf",
    );

    my $n = $ctk->fsplit(
        -dirsrc => "/path/to/source/dir", # Source directory
        -dirdst => "/path/to/destination/dir", # Destination directory
        -glob   => "*.txt",
        -lines  => 3,
        -format => '[FILE].part[PART]', # Format. Default: [FILE].part[PART]
    )

    my $n = $ctk->fjoin(
        -dirsrc => "/path/to/source/dir", # Source directory
        -dirdst => "/path/to/destination/dir", # Destination directory
        -glob   => "*.txt",
        -outfile => "join.txt",
    );

DESCRIPTION

File plugin

METHODS

fcopy
    my $n = $ctk->fcopy(
        -dirsrc => "/path/to/source/dir", # Source directory
        -dirdst => "/path/to/destination/dir", # Destination directory
        -glob   => "*.conf",
        -format => '[FILE].copy', # Format. Default: [FILE]
    );

Copies files from the source directory to the destination directory and returns how many files was copied

-dirin, -in, -input, -dirsrc, , -src

Specifies source directory

Default: current directory

-dirout, -out, -output, -dirdst, , -dst

Specifies desination directory

Default: current directory

-list, -mask, -glob, -file, -files, -regexp
    -list => [qw/ file1.txt file2.txt file3.* /]

List of files or globs

    -glob => "file.*"

Glob pattern

    -file => "file1.txt"

Name of file

    -regexp => qr/\.(cgi|pl)$/i

Regexp

Default: undef (all files)

-format, -callback, -cb
    -format => "[COUNT]_[FILE].copy.[TIME]"

Specifies format for output file

    -callback => sub {
        my $file_name = shift;
        my $file_number = shift;
        ...
        return $file_name;
    }

Callbacks allows you to modify the name of the output file manually

Default: "[FILE]"

Replacing keys: FILE, COUNT, TIME

fjoin
    my $n = $ctk->fjoin(
        -dirsrc => "/path/to/source/dir", # Source directory
        -dirdst => "/path/to/destination/dir", # Destination directory
        -glob   => "*.txt",
        -outfile => "join.txt",
    );

Join group of files (by mask from source directory) to one big file (concatenate). File writes to destination directory by output file name (fout)

    perl -MCTK::Command -e "fjoin(-mask=>qr/txt$/, -fout=>'foo.txt')" -- *

This is new features, added since CTK 1.18

fmove
    my $n = $ctk->fmove(
        -dirsrc => "/path/to/source/dir", # Source directory
        -dirdst => "/path/to/destination/dir", # Destination directory
        -glob   => "*.conf",
        -format => '[FILE]', # Format. Default: [FILE]
    );

Movies files from the source directory to the destination directory and returns how many files was moved

Format of arguments see "fcopy"

fremove
    my $n = $ctk->fremove(
        -dirsrc => "/path/to/source/dir", # Source directory
        -glob   => "*.conf",
    );

Removing files from the source directory

Format of arguments see "fcopy"

fsplit
    my $n = $ctk->fsplit(
        -dirsrc => "/path/to/source/dir", # Source directory
        -dirdst => "/path/to/destination/dir", # Destination directory
        -glob   => "*.txt",
        -lines  => 3,
        -format => '[FILE].part[PART]', # Format. Default: [FILE].part[PART]
    )

Split group of files to parts

-dirin, -in, -input, -dirsrc, , -src

Specifies source directory

Default: current directory

-dirout, -out, -output, -dirdst, , -dst

Specifies desination directory

Default: current directory

-list, -mask, -glob, -file, -files, -regexp
    -list => [qw/ file1.txt file2.txt file3.* /]

List of files or globs

    -glob => "file.*"

Glob pattern

    -file => "file1.txt"

Name of file

    -regexp => qr/\.(cgi|pl)$/i

Regexp

Default: undef (all files)

-limit,-lines,-rows,-n
    -lines => 5

Splits file by 5 lines

-format, -callback, -cb
    -format => "[COUNT]_[FILE].copy[TIME].part[PART]"

Specifies format for output file

    -callback => sub {
        my $input_file_name = shift;
        my $input_file_number = shift;
        my $output_file_number = shift; # Part number
        ...
        return $file_name;
    }

Callbacks allows you to modify the name of the output file manually

Default: "[FILE].part[PART]"

Replacing keys: FILE, COUNT, TIME, PART

REPLACING KEYS

FILE

Path and filename

FILENAME

Filename only

FILEEXT

File extension only

COUNT

Current number of file in sequence (for fcopy and fmove methods)

For fsplit method please use perl mask %i

TIME

Current time value (unix-time format, time())

HISTORY

See Changes file

DEPENDENCIES

CTK, CTK::Plugin, File::Find, File::Copy, Cwd

TO DO

See TODO file

BUGS

* none noted

SEE ALSO

CTK, CTK::Plugin

AUTHOR

Serż Minus (Sergey Lepenkov) http://www.serzik.com <abalama@cpan.org>

COPYRIGHT

Copyright (C) 1998-2019 D&D Corporation. All Rights Reserved

LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See LICENSE file and https://dev.perl.org/licenses/