Obtaining the Archive Attribute of a File on Windows Systems

Is it possible to check the archive attribute of Windows
files using Ruby? Or, even better, is it possible to get a
list of files that have active archive bits to then be able
to copy or move to a backup location?

You can do it using brute force:

require ‘find’

Find.find( ‘c:\temp’ ) do | aFile |
if attrib #{aFile} =~ /^A/
puts aFile
end
end

But it will (as far as I can see) not work on cygwin builds.

The command works in a Cygwin window.

and also on builds without cygwin :slight_smile:
I’m using prag build on windows…

:botp

You can do it using brute force:

require ‘find’

Find.find( ‘c:\temp’ ) do | aFile |
if attrib #{aFile} =~ /^A/
puts aFile
end
end

But it will (as far as I can see) not work on cygwin builds.

The command works in a Cygwin window.

and also on builds without cygwin :slight_smile:
I’m using prag build on windows…

The attrib command will work anywhere, it’s just that under the default W2K
CLI shell (cmd.exe) bacquotes don’t output anything for my PragProg 1.65
cygwin build. Under 4NT that I always use it works.

Regards,
M.