Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: Renaming non-ascii files

by jon12 (Novice)
on Jun 01, 2005 at 12:26 UTC ( [id://462402]=note: print w/replies, xml ) Need Help??


in reply to Re: Renaming non-ascii files
in thread Renaming non-ascii files

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^3: Renaming non-ascii files
by halley (Prior) on Jun 01, 2005 at 13:04 UTC
    Excuse me, jon12. It's not just that they're typos. If you want people to help you research and fix the functionality, you're going to have to provide something that compiles. People tinker with your code until they're SURE they are giving sound advice on how to fix it.

    It's like asking someone why the car won't start, but refusing to unlock the doors or open the hood. And I don't see anything sarcastic in the current version of davidj's posting.

    --
    [ e d @ h a l l e y . c c ]

Re^3: Renaming non-ascii files
by JamesNC (Chaplain) on Jun 01, 2005 at 13:20 UTC
    Try using the file test operators -B or -T to test for binary or text file perldoc -f -B. rename works for me on XP and 5.8.4 and works on both binary and plain text. Use a one liner and prove it to yourself  perl -le "rename 'somefile.xls', 'somefile2.xls'" I would suggest learning more about glob and the file test operators. I usually glob a list of files from the directory I want and then operate on the resulting list. There are lots of other ways to do this. Perhaps a simle example will get you started:
    my (@files) = glob "c:/progs/*"; #list of progs my (@dirs, @binfiles, @textfiles); foreach my $f( @files ) { -d $f ? push @dirs, $f : -f $f && -B $f ? push @binfiles, $f : -f $f && -T $f ? push @textfiles, $f : next; }

    JamesNC

      Please note that glob is a byzantine way of finding files and it relies heavily on the idea that no part of the glob pattern will contain a space. That idea is prevalent in much of the Unix mindset, but it easily fails on Win32 (unless you start and take care to quote the whitespace).

      If you're sure that your paths cannot and will not contain spaces, glob is convenient to use. If there is the possibility that the patterns will contain spaces, I found it more convenient to use File::Find (or File::Find::Rule) right from the start.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://462402]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (6)
As of 2024-04-18 06:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found