Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I'm using 'dir' in an attempt to glob a filespec and get Unicode filenames

I see, that does make it a bit more complicated. I used Win32::LongPath in the following, plus Text::Glob since you mentioned globs, but of course using a regex directly would be easier.

use warnings;
use strict;
use utf8;
use Text::Glob 'glob_to_regex';
use Win32::LongPath;
use File::Spec::Functions qw/no_upwards catfile/;
use IPC::Run3 'run3';
use Data::Dump;

my $glob = glob_to_regex('*Перл*');
my $dir = "C:\\Temp\\testuni";

my $dh = Win32::LongPath->new;
$dh->opendirL($dir) or die "unable to open $dir: $^E";
for my $file ( grep {/$glob/} no_upwards $dh->readdirL ) {
	my $path = catfile($dir, $file);
	my $sp = shortpathL($path);
	run3 ['hex', $sp], undef, \my $out;
	dd $path, $sp, $out;
}
$dh->closedirL;
Is 'hex' a command in your example?

I happened to have C:\Windows\hex.exe lying around, a simple hex dump tool from here.

Is there a reason that you used short pathnames?

In my first example, that's just how Path::Class returned them; in my example above I used them because it appeared to be easier to pass the pathname to the external command that way.

I'm using robocopy /l to get the total size of a folder, including subfolders. It's supposed to be a fast way to do that.

I tried running robocopy, and at least on my system the report it outputs doesn't mention file sizes anywhere. You might also want to look at e.g. the Perl version of du to see the algorithm used there.

I tried using run3, but I don't understand its rules and haven't got it working yet.

Again, it would be best if you can show an SSCCE.


In reply to Re^4: How to pass a folder name to Windows external commands? by haukex
in thread How to pass a folder name to Windows external commands? by freonpsandoz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2024-04-26 01:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found