NAME
Dir::Split - Split files of a directory to subdirectories
SYNOPSIS
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;
DESCRIPTION
Dir::Split splits files of a directory to subdirectories with a number or characters as suffix.
CONSTRUCTOR
new
Creates a new Dir::Split object.
$dir = Dir::Split->new(
source => $source_dir,
target => $target_dir,
);
sourcePath to source directory.
targetPath to target directory.
METHODS
split_num
Splits to subdirectories with number as suffix. Arguments to split_num() are options and not necessarily required.
$dir->split_num(
verbose => [0|1],
override => [0|1],
sort => 'asc',
limit => 5,
prefix => 'sub',
separator => '-',
continue => [0|1],
length => 5,
);
verboseBe verbose. Accepts a boolean, defaults to false.
overrideReplace existing files. Accepts a boolean, defaults to false.
sortSort mode. Accepts 'asc' for ascending, 'desc' for descending; defaults to ascending.
limitMaximum of files per subdirectory. Accepts a number, defaults to 5.
prefixPrefix of subdirectories. Accepts a string, defaults to 'sub'.
separatorSeparator between prefix and suffix of subdirectory. Accepts a string, defaults to '-'.
continueResume suffix from ones already existing. Accepts a boolean, defaults to false.
lengthLength of suffix. Accepts a number, defaults to 5.
split_char
Splits to subdirectories with characters as suffix. Arguments to split_char() are options and not necessarily required.
$dir->split_char(
verbose => [0|1],
override => [0|1],
prefix => 'sub',
separator => '-',
case => 'upper',
length => 1,
);
verboseBe verbose. Accepts a boolean, defaults to false.
overrideReplace existing files. Accepts a boolean, defaults to false.
prefixPrefix of subdirectories. Accepts a string, defaults to 'sub'.
separatorSeparator between prefix and suffix of subdirectory. Accepts a string, defaults to '-'.
caseCase of suffix. Accepts 'lower' for lower case, 'upper' for upper case; defaults to upper case.
lengthLength of suffix. Accepts a number, defaults to 1.
print_summary
Prints a summary.
EXAMPLES
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
BUGS & CAVEATS
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.
AUTHOR
Steven Schubiger <schubiger@cpan.org>
LICENSE
This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.