in reply to Contacting the author of a module?

I don't use Windows, but I note that the documentation for Win32::LongPath doesn't show renameL as a method you can call on the directory handle returned by opendirL, but only shows its use as a function - and the examples are all using absolute paths:

# should work renameL ('c:/file', 'c:/newfile'); # fails, can't move file to directory renameL ('d:/file', '.'); # should work for files renameL ('e:/file', 'f:/newfile'); # should work renameL ('d:/dir', 'd:/topdir/subdir'); # fails, can't move directory across volumes renameL ('c:/dir', 'd:/newdir');

So I think you should try using it as documented, and see if that works better. It is also possible that it will treat relative paths as being relative to the current directory, but I suggest trying that second after verifying that it works as documented for absolute paths.

Replies are listed 'Best First'.
Re^2: Contacting the author of a module?
by BernieC (Pilgrim) on Jan 06, 2023 at 13:30 UTC
    Great catch! I missed that. and as you suggested: using it properly works like a champ. THANKS!
      I expect that none of you really care about this or will run into this problem, but y'all were so helpful as I wandered on my fool's errand I'd like to share the end result of it. You might be amused at the way I got rid of the Unicode characters.. :o)
      #!/usr/bin/perl # Remove the Unicode characters from file names # $Id: removeunicode.pl 1.2 2023/01/07 00:21:49 bernie Exp $ use v5.10 ; use strict; use warnings ; use Getopt::Std ; # getopts(<flags>, \%args) ; my %args ; use Win32::LongPath ; getopts("v", \%args) or Usage(); sub Usage { die "Usage: removeunicode [-v] <DIR>\n" ; } my $dir = $ARGV[0] ; Usage() unless $dir ; chdir $dir or die "can't connect to $dir: $!\n" ; trace("connected to $dir") ; my $d = Win32::LongPath->new() ; $d->opendirL(".") or die "Can't open $dir: $!\n" ; for my $file ($d->readdirL($d)) { my $fixedfile = sanitize($file) ; next if $fixedfile eq $file ; # No unicode this filename trace("working on $file") ; trace("changing to $fixedfile") ; renameL($file, $fixedfile) or die "didn't rename! $!"; } exit ; #Remove all the unicode characters from a string sub sanitize { my $unicode = $_[0] ; my $ascii ; for my $char (split(//, $unicode)) { $ascii .= $char if ord($char) < 256 } return $ascii; } sub trace { say $_[0] if $args{v} }