in reply to Re: rename and create directories
in thread rename and create directories

Thanks guys, I had suspected that rename didn't support that but didn't know what alternative to seek. Now I'm stuck tryiing to make a regex that will chop the filename off of a directory string like c:\bla\did\dy\blah.txt to be c:\bla\did\dy. Can you answer this one as fast?

Currently I am splitting the string on "\" and reconstructing it without the last array element. Surely there is a better way.

Replies are listed 'Best First'.
Re^3: rename and create directories
by dimar (Curate) on Nov 30, 2004 at 22:39 UTC
    Currently I am splitting the string on "\" and reconstructing it without the last array element. Surely there is a better way.

    Indeed there is, use File::Basename, and thy foot shall step upon the path of goodly ways.

    ### ... sample snippet ... my ($basename,$path,$extension) = File::Basename::fileparse($fullpath,qw(.txt));