M
Marek
Hello all,
I am a perl beginner. So patience please!
I wrote a perl-script to find all unused pix of a web site. Now I
would like to move all those 168! pix from the folder pix to the
folder pix_out keeping the same hierarchy as in the original folder.
That means:
/Users/xxx/Documents/webpages/www.myproject.de/pix/fotos/thumbnails/
tn_munich28.jpg
should be renamed to:
/Users/xxx/Documents/webpages/www.myproject.de/pix_out/fotos/
thumbnails/tn_munich28.jpg
Only one folder is changing his name: pix -> pix_out And this with all
my 168 unused pix in different folders.
I was hoping, that the rename function would create the missing
folders, doing:
rename "/Users/xxx/Documents/webpages/www.myproject.de/pix/fotos/
thumbnails/tn_munich28.jpg", "/Users/xxx/Documents/webpages/
www.myproject.de/pix_out/fotos/thumbnails/tn_munich28.jpg";
But there is even no error message, trying to do it like this with one
test file. So probably I have to grep out the folders starting from
"pix"-folder until the file:
this would give in this example the folders fotos -> thumbnails which
are missing and which I have to create in pix_out - folder
My questions are:
How to grep these missing folders? Starting from pix, my hierarchy is
maximum 2 folders deep. But if there would be more folders?
how to test whether a folder is already created? I tried with:
if (-e ! $dir_pix_out)
#wrong!!
{
mkdir
$dir_pix_out;
}
thank you for your help
marek
I am a perl beginner. So patience please!
I wrote a perl-script to find all unused pix of a web site. Now I
would like to move all those 168! pix from the folder pix to the
folder pix_out keeping the same hierarchy as in the original folder.
That means:
/Users/xxx/Documents/webpages/www.myproject.de/pix/fotos/thumbnails/
tn_munich28.jpg
should be renamed to:
/Users/xxx/Documents/webpages/www.myproject.de/pix_out/fotos/
thumbnails/tn_munich28.jpg
Only one folder is changing his name: pix -> pix_out And this with all
my 168 unused pix in different folders.
I was hoping, that the rename function would create the missing
folders, doing:
rename "/Users/xxx/Documents/webpages/www.myproject.de/pix/fotos/
thumbnails/tn_munich28.jpg", "/Users/xxx/Documents/webpages/
www.myproject.de/pix_out/fotos/thumbnails/tn_munich28.jpg";
But there is even no error message, trying to do it like this with one
test file. So probably I have to grep out the folders starting from
"pix"-folder until the file:
this would give in this example the folders fotos -> thumbnails which
are missing and which I have to create in pix_out - folder
My questions are:
How to grep these missing folders? Starting from pix, my hierarchy is
maximum 2 folders deep. But if there would be more folders?
how to test whether a folder is already created? I tried with:
if (-e ! $dir_pix_out)
#wrong!!
{
mkdir
$dir_pix_out;
}
thank you for your help
marek