datmrman has asked for the wisdom of the Perl Monks concerning the following question:
Instead of the rename, I have tried:#!/usr/bin/perl -w use File::Copy; use File::Path; use strict; use warnings; .... /* $filename, $pat_name, $study_date, $study_time, $series_num are define +d */ .... my ($new_filename, $dir_path); #create new pathname $dir_path = "$pat_name/$study_date-$study_time/$series_num"; #create new filename $new_filename="$pat_name-$study_date-$study_time-$series_num-$image_nu +m.dcm"; eval { mkpath($dir_path) }; if ($@) { print "Couldn't create $dir_path: $@"; } $new_filename = "$dir_path/$new_filename"; rename($filename,$new_filename) or die( "could not rename $filename to + $new_filename: $!\n" );
orsystem("mv",$filename,$new_filename) or die("could not rename $filenam +e to $new_filename: $!\n");
with no luck. Here is a sample print out:move($filename,$new_filename) or die("could not rename $filename to $n +ew_filename: $!\n");
It is not a question of permission because permissions are set as a+rwx. Any help will be appreciated. I have been struggling with this for a while. I am using Perl 5.8.5.could not rename 1.2.840.113619.2.55.1.1762883246.3061.1000220985.209/ +1.2.840.113619.2.55.1.1762883246.3061.1000220985.210/1.2.840.113619.2 +.55.1.1762883246.3061.1000220985.212.dcm to S000109A33/20010911-12560 +2/1/S000109A33-20010911-125602-1-2.dcm: Is a directory
I also tried writing my own recursive mkdir subfunction, but the -e and -d misbehave and claims a folder exists when it doesn't. With this code:if( ! -e $dir_path) { system("mkdir","-p",$dir_path); }
I get an "Illegal seek" error. Please help! Thank you.system("mkdir","-p",$dir_path) or warn("could not make dir $dir_path: +$!\n");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Weird rename error
by GrandFather (Saint) on Jul 26, 2005 at 20:42 UTC | |
by datmrman (Initiate) on Jul 26, 2005 at 20:53 UTC | |
by Anonymous Monk on Jul 27, 2005 at 03:32 UTC | |
by datmrman (Initiate) on Jul 27, 2005 at 18:56 UTC |