How to find all files in a subdirectory read which are writable (=not read-only) ?

  • Thread starter Thread starter Tim Tuples
  • Start date Start date
T

Tim Tuples

Is there a tool (preferable a command line tool) which lists all files in a subdirectory tree
which are writable?

Tim
 
Tim Tuples said:
Is there a tool (preferable a command line tool) which lists all files in
a subdirectory tree
which are writable?

Tim

The DIR command:

DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N]
[/O[[:]sortorder]] [/P] [/Q] [/S] [/T[[:]timefield]] [/W] [/X] [/4]

[drive:][path][filename]
Specifies drive, directory, and/or files to list.

/A Displays files with specified attributes.
attributes D Directories R Read-only files
H Hidden files A Files ready for archiving
S System files - Prefix meaning not

Looks like the "prefix meaning not" option is the key to what you're trying
to do. To see all options for the dir command type this at a command line:
DIR /?

As an alternative, view the directory in Explorer. Right click the column
headings at the top and enable the Attributes column. Then, sort on that
column to group the files by attribute.
 
I suggest:

dir /S/A-D-R/B

(leave out directories and Read-only-files)

Armin

Doug Kanter said:
Tim Tuples said:
Is there a tool (preferable a command line tool) which lists all files in
a subdirectory tree
which are writable?

Tim

The DIR command:

DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N]
[/O[[:]sortorder]] [/P] [/Q] [/S] [/T[[:]timefield]] [/W] [/X] [/4]

[drive:][path][filename]
Specifies drive, directory, and/or files to list.

/A Displays files with specified attributes.
attributes D Directories R Read-only files
H Hidden files A Files ready for archiving
S System files - Prefix meaning not

Looks like the "prefix meaning not" option is the key to what you're
trying to do. To see all options for the dir command type this at a
command line:
DIR /?

As an alternative, view the directory in Explorer. Right click the column
headings at the top and enable the Attributes column. Then, sort on that
column to group the files by attribute.
 
Tim said:
Is there a tool (preferable a command line tool) which lists all files in a subdirectory tree
which are writable?

Tim

The DIR command with the /A:-R-H switch will list all with 'read only'
and Hidden not set. (and maybe add -S for not system files)

But there may still be some that are open in programs or system, and
which currently cannot be opened for writing
 
Example output:
C:\WINDOWS\system32\winlogon.exe is not writable (Permission denied)
C:\WINDOWS\system32\accwiz.exe is writable

This is a For command in a command prompt. Type For in help or For /? in a command prompt to alter to suit your requirements - you probably don't have a user with my name and I name files whatever windows chooses (should see how many files I have that start New Text Document .....something). Also checking files protected by Windows File Protection will cause it to kick in and replace the file (it replaces files if there is a file operation on the file which there is here - we open it for writing). If it can't find the replacement files it will give up for a limited user and pester a administrator for a XP CD. The files haven't changed so tell it to go away and find it's own CD if it wants it so bad.

For /r "c:\windows\system32" %A IN (*.exe) DO cscript "C:\Documents and Settings
\David Candy\Desktop\New Text Document1.vbs" "%A" >>"%userprofile%\desktop\test.
txt"

This is the worker part. Copy the lines into a text file and call it SomethingSensible.vbs
Put it somewhere and edit the For line with it's new path and name

On Error Resume Next
Set objArgs = WScript.Arguments
Set fso = CreateObject("Scripting.FileSystemObject")
Set srcfile = fso.GetFile(objArgs(0))
If err.number = 0 then
Set TS = srcFile.OpenAsTextStream(2, -2)
If err.number = 0 then
wscript.echo srcFile.Path & vbtab & " is writable"
else
wscript.echo srcFile.Path & vbtab & " is not writable (" & err.description & ")"
err.clear
End If
Else
wscript.echo objArgs(0) & " generated an error while attempting to get a reference. Error returned was " & err.description
End If
--
----------------------------------------------------------
http://www.uscricket.com
Armin Freiberg said:
I suggest:

dir /S/A-D-R/B

(leave out directories and Read-only-files)

Armin

Doug Kanter said:
Tim Tuples said:
Is there a tool (preferable a command line tool) which lists all files in
a subdirectory tree
which are writable?

Tim

The DIR command:

DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N]
[/O[[:]sortorder]] [/P] [/Q] [/S] [/T[[:]timefield]] [/W] [/X] [/4]

[drive:][path][filename]
Specifies drive, directory, and/or files to list.

/A Displays files with specified attributes.
attributes D Directories R Read-only files
H Hidden files A Files ready for archiving
S System files - Prefix meaning not

Looks like the "prefix meaning not" option is the key to what you're
trying to do. To see all options for the dir command type this at a
command line:
DIR /?

As an alternative, view the directory in Explorer. Right click the column
headings at the top and enable the Attributes column. Then, sort on that
column to group the files by attribute.
 
Back
Top