Dir::Split - Split files of a directory to subdirectories
use Dir::Split; $dir = Dir::Split->new( source => $source_dir, target => $target_dir, ); $dir->split_num; # or $dir->split_num( verbose => 1, ... ); $dir->print_summary;
Dir::Split splits files of a directory to subdirectories with a number or characters as suffix.
Dir::Split
Creates a new Dir::Split object.
$dir = Dir::Split->new( source => $source_dir, target => $target_dir, );
source
Path to source directory.
target
Path to target directory.
Splits to subdirectories with number as suffix. Arguments to split_num() are options and not necessarily required.
split_num()
$dir->split_num( verbose => [0|1], override => [0|1], sort => 'asc', limit => 5, prefix => 'sub', separator => '-', continue => [0|1], length => 5, );
verbose
Be verbose. Accepts a boolean, defaults to false.
override
Replace existing files. Accepts a boolean, defaults to false.
sort
Sort mode. Accepts 'asc' for ascending, 'desc' for descending; defaults to ascending.
limit
Maximum of files per subdirectory. Accepts a number, defaults to 5.
prefix
Prefix of subdirectories. Accepts a string, defaults to 'sub'.
separator
Separator between prefix and suffix of subdirectory. Accepts a string, defaults to '-'.
continue
Resume suffix from ones already existing. Accepts a boolean, defaults to false.
length
Length of suffix. Accepts a number, defaults to 5.
Splits to subdirectories with characters as suffix. Arguments to split_char() are options and not necessarily required.
split_char()
$dir->split_char( verbose => [0|1], override => [0|1], prefix => 'sub', separator => '-', case => 'upper', length => 1, );
case
Case of suffix. Accepts 'lower' for lower case, 'upper' for upper case; defaults to upper case.
Length of suffix. Accepts a number, defaults to 1.
Prints a summary.
Assume the source directory contains following files:
+- _123 +- abcd +- efgh +- ijkl +- mnop
Splitting the source to the target directory could result in:
number as suffix
+- sub-00001 +-- _123 +-- abcd +- sub-00002 +-- efgh +-- ijkl +- sub-00003 +-- mnop
characters as suffix
+- sub-_ +-- _123 +- sub-A +-- abcd +- sub-E +-- efgh +- sub-I +-- ijkl +- sub-M +-- mnop
As of v0.80_01, currently no value is returned from the splitting methods. Also, direct access to global tracking and debug variables has been removed. Furthermore, unlinking of source files and directories must be handled manually.
v0.80_01
Steven Schubiger <schubiger@cpan.org>
This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.
See http://dev.perl.org/licenses/
To install Dir::Split, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Dir::Split
CPAN shell
perl -MCPAN -e shell install Dir::Split
For more information on module installation, please visit the detailed CPAN module installation guide.