Jump to content

Recommended Posts

Posted (edited)

Does anyone know how to change the attributes of several files to read-only with LISP?

Edited by antistar
Posted

You can do it with VLisp this has been commented on before search here.

Posted

Thanks Bigal, for reply.

I found this routine, but it only works for one file. I would like to change several files at once.

(defun c:SetRO (/ afile fso ofile ro)
;;by stig.madsen
 (cond
   ((and (setq aFile (getfiled "" "" "" 4))
         (setq fso (vlax-create-object "Scripting.FilesystemObject"))
         (setq oFile (vlax-invoke fso 'GetFile aFile))
    )
    (vlax-put-property oFile 'Attributes (setq ro (- 1 (logand 1 (vlax-get-property oFile 'Attributes)))))
    (princ (strcat "File set to " (nth ro '("Read-write" "Read-only"))))
    (vlax-release-object oFile)
    (vlax-release-object fso)
   )
 )
 (princ)
)

Posted

Just build-up the list of files (see VL-DIRECTORy-FILES function) and use FOREACH to adjust their properties.

An alternative for adjusting the properties of files is DOS_ATTRIB from DosLIB pack (freeware); please note that this supports wildcard characters.

Posted
Just build-up the list of files (see VL-DIRECTORy-FILES function) and use FOREACH to adjust their properties.

An alternative for adjusting the properties of files is DOS_ATTRIB from DosLIB pack (freeware); please note that this supports wildcard characters.

 

Would calling the LISP from a script, and running a batch through ScriptPro work as well? Perhaps a more simplistic approach?

Posted

Re script change (defun c:SetRO (/ afile fso ofile ro) to (defun SetRO (afile / fso ofile ro)

 

The script

(load "setro")

(setro "C:\acadtemp\dwg1")

(setro "C:\acadtemp\dwg2")

[/code]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...