Failing with Dir.glob results

Hello,
My script is failing at the following move command, right after the
capturing of a bunch of files in a directory. My glob is a big one. It’s
checking against 49 different file prefixes. Is that a problem? All I
want it to do for now is copy any files that conform to one of those
prefixes.

Thanks.


require ‘FileUtils’

ps2kfiles =
Dir.glob("{aacmc7,acm059,acm061,acmc59,acmt59,adc064,adm065,cbncc7,cgmpr,cpslit,cpsmco,edc131,edt131,eeomc7,emgc15,hcc201,hcci01,hct201,hcti01,hla020,hlai20,hlb020,hlbi20,hltc20,hlti20,ierc78,itc101,jsc047,lrc013,lrfl21,lrnm21,lrrc21,lrrc22,lrrc24,lrrc37,lrrc49,lrrc74,lrrmc6,lrrt37,lrt013,mopc68,mopd68,mopec8,mopt68,pgc117,pslc45,psvc45,rtc129,uln007,}*.pdf")

ps2kfiles.each do |ps2kfile|
FileUtils.mv ‘#{ps2kfile}’, ‘C:/scripts/ruby/temp/test/indextemp/ps2k/’
end

On Jun 19, 2006, at 15:11, Peter B. wrote:

Hello,
My script is failing at the following move command, right after the
capturing of a bunch of files in a directory. My glob is a big one.
It’s
checking against 49 different file prefixes. Is that a problem? All I
want it to do for now is copy any files that conform to one of those
prefixes.

What’s the nature of the failure? Do you get any sort of error message?

If you reduce the number of prefixes, does that solve the problem?
For example, does this work:
Dir.glob("{aacmc7, acm059}*.pdf")

What about this?
Dir.glob(“aacmc7*.pdf”)

Sorry I can’t answer specifically, but answering those questions
ought to get you at least part of the way to what the real problem is.

matthew smillie.

Hi,

At Mon, 19 Jun 2006 23:11:44 +0900,
Peter B. wrote in [ruby-talk:198037]:

ps2kfiles =
Dir.glob("{aacmc7,acm059,acm061,acmc59,acmt59,adc064,adm065,cbncc7,cgmpr,cpslit,cpsmco,edc131,edt131,eeomc7,emgc15,hcc201,hcci01,hct201,hcti01,hla020,hlai20,hlb020,hlbi20,hltc20,hlti20,ierc78,itc101,jsc047,lrc013,lrfl21,lrnm21,lrrc21,lrrc22,lrrc24,lrrc37,lrrc49,lrrc74,lrrmc6,lrrt37,lrt013,mopc68,mopd68,mopec8,mopt68,pgc117,pslc45,psvc45,rtc129,uln007,}*.pdf")

This globs aacmc7*.pdf, acm059*.pdf, … and *.pdf. So
prefixed files will be listed twice.

On 6/19/06, Peter B. [email protected] wrote:

require ‘FileUtils’

ps2kfiles =
Dir.glob("{aacmc7,acm059,acm061,acmc59,acmt59,adc064,adm065,cbncc7,cgmpr,cpslit,cpsmco,edc131,edt131,eeomc7,emgc15,hcc201,hcci01,hct201,hcti01,hla020,hlai20,hlb020,hlbi20,hltc20,hlti20,ierc78,itc101,jsc047,lrc013,lrfl21,lrnm21,lrrc21,lrrc22,lrrc24,lrrc37,lrrc49,lrrc74,lrrmc6,lrrt37,lrt013,mopc68,mopd68,mopec8,mopt68,pgc117,pslc45,psvc45,rtc129,uln007,}*.pdf")

ps2kfiles.each do |ps2kfile|
FileUtils.mv ‘#{ps2kfile}’, ‘C:/scripts/ruby/temp/test/indextemp/ps2k/’
end

Did you mean to have that last comma at the end of all those prefixes?
(prefixi? prefixin’? :wink: )

—John

Matthew S. wrote:

On Jun 19, 2006, at 15:11, Peter B. wrote:

Hello,
My script is failing at the following move command, right after the
capturing of a bunch of files in a directory. My glob is a big one.
It’s
checking against 49 different file prefixes. Is that a problem? All I
want it to do for now is copy any files that conform to one of those
prefixes.

What’s the nature of the failure? Do you get any sort of error message?

If you reduce the number of prefixes, does that solve the problem?
For example, does this work:
Dir.glob("{aacmc7, acm059}*.pdf")

What about this?
Dir.glob(“aacmc7*.pdf”)

Sorry I can’t answer specifically, but answering those questions
ought to get you at least part of the way to what the real problem is.

matthew smillie.

Yes, absolutely. I have no problems when I have far fewer glob choices.
But, I donâ??t think my problem here is the globbing itself. Thatâ??s what
Iâ??ve discovered. My error message points to the move command. Iâ??ve since
corrected and made this file useable by replacing my FileUtils move with
a simple system move command.

Thank you for your help.

John G. wrote:

On 6/19/06, Peter B. [email protected] wrote:

require ‘FileUtils’

ps2kfiles =
Dir.glob("{aacmc7,acm059,acm061,acmc59,acmt59,adc064,adm065,cbncc7,cgmpr,cpslit,cpsmco,edc131,edt131,eeomc7,emgc15,hcc201,hcci01,hct201,hcti01,hla020,hlai20,hlb020,hlbi20,hltc20,hlti20,ierc78,itc101,jsc047,lrc013,lrfl21,lrnm21,lrrc21,lrrc22,lrrc24,lrrc37,lrrc49,lrrc74,lrrmc6,lrrt37,lrt013,mopc68,mopd68,mopec8,mopt68,pgc117,pslc45,psvc45,rtc129,uln007,}*.pdf")

ps2kfiles.each do |ps2kfile|
FileUtils.mv ‘#{ps2kfile}’, ‘C:/scripts/ruby/temp/test/indextemp/ps2k/’
end

Did you mean to have that last comma at the end of all those prefixes?
(prefixi? prefixin’? :wink: )

—John

Youâ??re right. I did see that, and, I deleted it. It didn’t change my
results, though. But, as I told Matthew, it appears my problem here was
not the glob itself, but the FileUtils move command. I replaced that,
for now, with a simple system move command, and it works.

Thanks!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs