Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Renaming non-ascii files

by davidj (Priest)
on Jun 01, 2005 at 11:41 UTC ( #462394=note: print w/ replies, xml ) Need Help??


in reply to Renaming non-ascii files

First of all, your code doesn't even compile. There are two errors:

elsif($myfile =~ m/[\? ]+(\([0-9]+\))?\.(\w+)\i)
needs to be changed to
elsif($myfile =~ m/[\? ]+(\([0-9]+\))?\.(\w+)/i)
and
$newname = join "." $temp, $ext;
needs to be changed to
$newname = join ".", $temp, $ext;
At that point it will compile. Please post the code you are actually using.
davidj


Comment on Re: Renaming non-ascii files
Select or Download Code
Re^2: Renaming non-ascii files
by jon12 (Novice) on Jun 01, 2005 at 12:26 UTC
    Excuse me davidj, didn't mean to stress you out over a few typos. I prefer some help, that is why i posted, not sarcastic comments and downgrades.
      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 ]

      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
Node Status?
node history
Node Type: note [id://462394]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2014-09-23 07:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (211 votes), past polls