in reply to Moving Files
If the target directory .../tmp is not present, the file to be moved will be placed in the parent directory instead and will be renamed to tmp. So I would make sure beforehand that the target directory exists.
For the creation of directories of any depth, use mkpath() from core module File::Path. For moving you could use Perl's File::Copy module. It has a portable move() function. I would do it like this (untested):
# read trans barcode $primer = Util::Util::trim(Util::Util::fileDecode($transFile)); # set transaction folder path my $transPath = "plsTrans/" . $primer . "/tmp/"; use File::Path qw(mkpath); # create the target directory if there is none if (!-d $transPath) { mkpath $transPath or die "cannot create target directory $transPat +h:$!\n"; } use File::Copy qw(move); move($transFile, $transPath . $transFile) or die "move to $transPath failed: $!";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Moving Files
by rottmanja (Initiate) on Aug 07, 2008 at 18:29 UTC |