Jump to content
Macro Express Forums

How To: Get The Attributes Of A File


Recommended Posts

Macro Express does not have a built-in command to return the attributes of a file such as ReadOnly, Hidden, System, and Archive. So, you can use this macro to do it instead. It runs a VBScript script program. The script is generated by the macro, saved to a unique file name in your temp folder, and is then run using the Program Launch command. All temporary files are erased before the macro terminates.

 

The name of the target file, the one that you want to get the attributes from, is saved to a Key in an INI file (saved in your temp folder), which is read by the script when called. The script gets the target file attributes and returns them as a comma delimited string back to the INI file under another Key. When the script is done the macro takes control back and reads the attributes string from the INI file.

 

The macro does the following:

  1. Gets the name of your temp folder
  2. Generates a unique file name
  3. Prompts for the target file name and saves it to the INI file
  4. Generates the VBScript script and saves it to the temp folder
  5. Runs the script, getting the attributes and saving them to the INI file
  6. Reads the INI file and displays the results
  7. Erases the files generated by the macro.

The attributes returned are:

  • Normal
  • ReadOnly
  • Hidden
  • System
  • Archive

If a file has more than one attribute then they are returned as a comma delimited string such as "Hidden,System,Archive". If an error occurs in the script then a blank string will be returned. Tested under Win'XP, Win'2k, and Win'98.

Get_File_Attributes.zip

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Loading...
 Share

×
×
  • Create New...