
CaseElse
New User
Jun 14, 2011, 11:11 PM
Post #1 of 1
(196 views)
|
|
Need DirSelect for unmounted network shares
|
Can't Post
|
|
Hi all, I need to write a script to copy folders from one network share to another. To do this the user has to choose the directory (only directories, no single files) which he wants to copy. This network shares are not mountet on the client systems (WinXP and Win7). Mounting is no option for me, because i don't know which drive letters are already in use. I tried to configure a user selection with DirSelect ( http://search.cpan.org/~mjcarman/Tk-DirSelect-1.11/DirSelect.pm ) but this doesn't work for unmounted NFS shares. Afterwards i tried to build something on my own with Find and Tree. Result:
#!/usr/bin/perl use strict; use warnings; use Tk; use Tk::Tree; use File::Find; my $root = '//srv0c001/io$/'; my @aFolders; # Create Gui my $mw = MainWindow -> new; my $text = 'Doubleclick or <Enter> line'; $mw -> Label (-textvariable => \$text) -> pack (-side => 'top'); my $tree = $mw -> Tree (-command => sub {$text = shift}, -width => 30, -height => 20) -> pack (-anchor => 'nw'); # Search for Subdirectories find(\&wanted, $root); @aFolders = sort(@aFolders); # add directories to tree foreach(@aFolders) { my @t = split (/\./, $_); $tree->add($_, -text => $t[-1]); } $tree->autosetmode(); $mw -> Button (-text => 'Exit', -command => sub {exit}) -> pack (); MainLoop; sub wanted { if (-d) { $File::Find::name =~ s/.*io$\/?//g; $File::Find::name =~ s/\//\./g; if ($File::Find::name ne '') { push(@aFolders, "$File::Find::name"); } } } Problem is that: 1. My script is way to slow. There are about 30000 subfolders and 200000 files in the share. I don't know how long it takes to check all of these, but it's way to long. 2. I want the folder selection as a subroutine so that only the selected path is returned. But i don't know how to do this Short way to say it: I need something like DirSelect which works for unmounted network shares By the way: this is my first perl project. I normally use other scripting languages, but in this case i need to do it in perl. Might be that there is a solution for my problem out there, but i havn't find it Thanks in advance for anybody who's trying to help Regards, CaseElse PS: Sorry for my bad english
|