I have been screwing with this for the last hour, and I still cant get
it (so frustrating when you get stuck on matters that seem trivial).
I am trying to delete all the contents from the temporary internet files
in vista, and I keep getting an invalid argeument error.
cache_dir = ENV['USERPROFILE'] +
"\\AppData\\Local\\Microsoft\\Windows\\Temporary Internet Files\\*.*"
FileUtils.rm(cache_dir)
I have tried several different variations, of backtick, single quotes,
double quotes, etc, etc....even tried deleting a single file, and it
always gives me the same error. Also tried rm_r, rm_rf...still no luck.
could someone explain to me what I am doing wrong? thanks!
I have been screwing with this for the last hour, and I still cant get
it (so frustrating when you get stuck on matters that seem trivial).
I am trying to delete all the contents from the temporary internet files
in vista, and I keep getting an invalid argeument error.
cache_dir = ENV['USERPROFILE'] +
"\\AppData\\Local\\Microsoft\\Windows\\Temporary Internet Files\\*.*"
FileUtils.rm(cache_dir)
I have tried several different variations, of backtick, single quotes,
double quotes, etc, etc....even tried deleting a single file, and it
always gives me the same error. Also tried rm_r, rm_rf...still no luck.
could someone explain to me what I am doing wrong? thanks!
It looks like you're trying to remove all the files in the directory at once. Bear in mind that FileUtils.rm wants a _list_ of filenames, not a pattern to match. You can specify a list of filenames by accumulating them in an array and then using the splat operator:
filenames = whatever it takes to get all the filename in an array
FileUtils.rm(*filenames)
I have tried several different variations, of backtick, single quotes,
double quotes, etc, etc....even tried deleting a single file, and it
always gives me the same error. Also tried rm_r, rm_rf...still no luck.
could someone explain to me what I am doing wrong? thanks!
It looks like you're trying to remove all the files in the directory at
once. Bear in mind that FileUtils.rm wants a _list_ of filenames, not a
pattern to match. You can specify a list of filenames by accumulating
them in an array and then using the splat operator:
filenames = whatever it takes to get all the filename in an array
FileUtils.rm(*filenames)
that makes much more sense. what threw me off was the * in the following
line in the rdoc
FileUtils.rm Dir.glob('*.so')
Did some reading up on Dir.glob and it makes much more sense now.
Thanks!
I have tried several different variations, of backtick, single quotes,
double quotes, etc, etc....even tried deleting a single file, and it
always gives me the same error. Also tried rm_r, rm_rf...still no luck.
could someone explain to me what I am doing wrong? thanks!
It looks like you're trying to remove all the files in the directory at
once. Bear in mind that FileUtils.rm wants a _list_ of filenames, not a
pattern to match. You can specify a list of filenames by accumulating
them in an array and then using the splat operator:
filenames = whatever it takes to get all the filename in an array
FileUtils.rm(*filenames)
So I am stuck again on this...I have the following code:
dir = Dir.open("c:\\myDir\\delete\\")
FileUtils.rm(dir.entries.reject{|e| /\.{1,2}$/ =~ e})
the problem is, that the dir.entries only returns the filename of each
entry...is there anyway to have them expanded?
I have tried several different variations, of backtick, single quotes,
double quotes, etc, etc....even tried deleting a single file, and it
always gives me the same error. Also tried rm_r, rm_rf...still no luck.
could someone explain to me what I am doing wrong? thanks!
It looks like you're trying to remove all the files in the directory at
once. Bear in mind that FileUtils.rm wants a _list_ of filenames, not a
pattern to match. You can specify a list of filenames by accumulating
them in an array and then using the splat operator:
filenames = whatever it takes to get all the filename in an array
FileUtils.rm(*filenames)
So I am stuck again on this...I have the following code:
dir = Dir.open("c:\\myDir\\delete\\")
FileUtils.rm(dir.entries.reject{|e| /\.{1,2}$/ =~ e})
the problem is, that the dir.entries only returns the filename of each entry...is there anyway to have them expanded
btw, before running the above in irb, pls press ctrl-c+enter or
restart your irb first. your irb prompt is hinting a continuation on a
quote
kind regards -botp
···
On Feb 9, 2008 10:08 AM, an an <dtown22@gmail.com> wrote:
still no luck...here is exactly what I have typed into irb:
irb(main):011:1' Dir.glob("c:\\*")
irb(main):012:1' print Dir.glob("C:\\*")
none of these commands returned anything....any idea why?
none of these commands returned anything....any idea why?
Well...it _might_ be a Windows thing, but what did you type in before those lines? You seem to be within a quote.
Notice your prompt:
irb(main):003:1'
^
Should be a > (greater than sign)
For instance:
irb(main):001:0> ' <- I just started a string
irb(main):002:0' <- Now the prompt is different
irb(main):003:0' Until I close the string, it will remain that way
irb(main):004:0' here I close it -> '
=> " <- I just started a string\n<- Now the prompt is different\nUntil I close the string, it will remain that way\nhere I close it -> "
irb(main):005:0> puts "Now we're back to normal"
Now we're back to normal
=> nil