File.rename failing after a few thousand successes . . .

P

Peter Bailey

Hello,
With help from this forum, I've been successful in parsing through
directories of thousands of graphics files. I need to determine which
files are postscript EPS files. Any files that aren't EPS files I can
assume are TIFF files. I have to do this because our [unix] publishing
system doesn't use file extensions, so, in its image library, all
graphics files have no extensions. I'm needing to parse through these
files to get rid of any color files, make them grayscale. Anyway, I have
a directory now with over 23,000 files in it. I've run a script with
this clause in it.

Dir.glob("*").each do |file|
if /%!PS-Adobe/ =~ open(file) {|f| f.gets}
File.rename(file, file + ".eps")
end
end

It runs just fine and does a rename for 3123 files. But, then, suddenly,
it fails with a message:

Exception: Permission denied - in

Any ideas?

Thanks,
Peter
 
A

Axel Etzold

-------- Original-Nachricht --------
Datum: Mon, 15 Oct 2007 21:21:36 +0900
Von: Peter Bailey <[email protected]>
An: (e-mail address removed)
Betreff: File.rename failing after a few thousand successes . . .
Hello,
With help from this forum, I've been successful in parsing through
directories of thousands of graphics files. I need to determine which
files are postscript EPS files. Any files that aren't EPS files I can
assume are TIFF files. I have to do this because our [unix] publishing
system doesn't use file extensions, so, in its image library, all
graphics files have no extensions. I'm needing to parse through these
files to get rid of any color files, make them grayscale. Anyway, I have
a directory now with over 23,000 files in it. I've run a script with
this clause in it.

Dir.glob("*").each do |file|
if /%!PS-Adobe/ =~ open(file) {|f| f.gets}
File.rename(file, file + ".eps")
end
end

It runs just fine and does a rename for 3123 files. But, then, suddenly,
it fails with a message:

Exception: Permission denied - in

Any ideas?

Thanks,
Peter

Dear Peter,

you don't have the right to read or to write that particular file,
maybe because it was created by another user or by root, and now
you're running your Ruby script as a normal user.
On the command line, you can change the rights to read, write and
execute files, as root, using
the chmod command.

http://en.wikipedia.org/wiki/Chmod

Best regards,

Axel
 
P

Peter Hickman

You need to get the script to display the name of the file that it
failed on (unless you simply didn't show it in your excerpt) and then
look at the permissions for the file in question.

Also it would be a good idea to catch the exception in your code so that
you can report the error and then carry on. Also make sure that you do
not process the any files that you have already processed on a previous
run by ignoring file names that end in ".eps".
 
P

Peter Bailey

Axel said:
-------- Original-Nachricht --------


Dear Peter,

you don't have the right to read or to write that particular file,
maybe because it was created by another user or by root, and now
you're running your Ruby script as a normal user.
On the command line, you can change the rights to read, write and
execute files, as root, using
the chmod command.

http://en.wikipedia.org/wiki/Chmod

Best regards,

Axel

Thanks, Axel. Well, yes, the original files are on Unix, but, all my
work is happening on a Windows server. I copy it over via SAMBA. But,
I'm a network administrator with full rights on the server. Maybe the
copying via SAMBA pulled over some weird permissions or something. I'll
look into this further. Thanks again.
 
R

Roger Pack

I've had weird stuff happen on NFS before--using a local drive worked.
GL!

Peter said:
Hello,
With help from this forum, I've been successful in parsing through
directories of thousands of graphics files. I need to determine which
files are postscript EPS files. Any files that aren't EPS files I can
assume are TIFF files. I have to do this because our [unix] publishing
system doesn't use file extensions, so, in its image library, all
graphics files have no extensions. I'm needing to parse through these
files to get rid of any color files, make them grayscale. Anyway, I have
a directory now with over 23,000 files in it. I've run a script with
this clause in it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,781
Messages
2,569,616
Members
45,306
Latest member
TeddyWeath

Latest Threads

Top