Click here to Skip to main content
15,885,767 members
Articles / Programming Languages / VBScript
Article

PrintDirectory - How to save a file's comments to a .txt file

Rate me:
Please Sign up or sign in to vote.
2.00/5 (3 votes)
21 Nov 20063 min read 30.2K   268   8   1
Save a file's comments to a .txt file.

Sample Image

Introduction

As seen above, this script will save to a file (c:\directory_list_mmddyyyy.txt) a listing of a folder of your choice. It first saves the date and time the script was run, followed by the script's name, and your selection. Starting with the main folder, it saves the folder name, size, and the date created. Next, it goes through the folder saving the file name, size, date created, and the comments, if any. (The comments are those shown when a file is right-clicked and the Summary tab is selected.). But it doesn't stop there. It continues through sub-folders, sub-sub-folders, etc., and files until done. So what? Well, you may have several folders and hundreds of files with short descriptions. When you run this script, you'll probably find that several of them, even though they have different names, share the same information. Also, entering the saved file into a database will broaden your choice of keywords. Note: The output is delimited with tabs, but due to different file name lengths, file size, and comments, it will require some minor housecleaning.

Background

I used AutoItV3 to write my first version of PrintDirectory. AutoIt is an easy and flexible keyboard macro generator. I then started reading about VBScript, of which I had no knowledge. I used Microsoft's VBScript Reference Guide and Do-It-Yourself Script Center to become self-taught. I knew what to write, but not how. I used different modules. I tested (using the Script Debugger IDE and ConTEXT), reviewed variables, deleted and added code, then retested each one until they worked independently. Now, I had to put them together and here is the final product.

Using the code

Double-click on PrintDirectory.zip and extract the file anywhere you want, preferably the root directory. When you double-click on PrintDirectory.vbs a standard listbox appears. Click on the folder you want it saved and select OK. The next step has two options. Press '1' (the default) and 'enter', and the output will be saved as shown above (pressing 'enter' alone will produce the same output) . Press '2' and 'enter' if you want the folder name to be saved between the file name and the size. That's it.

History

I know that I've made over a hundred changes since I started. I finalized my numbering system to the following: pd_mmddyyyy_hhmmss.vbs. Its self-explanatory. I've made two changes since July 2006. The first was to get the file size from another source, which is more accurate. The last change I made was to automatically save the extended file properties to an array (arrEFP(34)).

References and Software used

I used OpenOffice.org to write the RTF file, AceHTML to convert it to HTML, ScreenGrabPro to get the screenshot, ConTEXT to test and run PrintDirectory.vbs, and PowerArchiver to zip everything together. All freeware.
  • ConTEXT - freeware text editor

    Supports multiple languages: HTML, C/C++, JavaScript, VBScript, etc.

  • MSDN Library

    Samples, reference guide, articles, tools, etc.

  • Windows Script 5.6 for Windows XP and Windows 2000

    This download installs Microsoft® Windows® Script containing Visual Basic® Script Edition (VBScript) Version 5.6, JScript® Version 5.6, Windows Script Components, Windows Script Host 5.6, and Windows Script Runtime Version 5.6.

  • Microsoft Download Center

    This link will install almost 2,000 scripts with descriptions, requirements, and search capability.

    The Do-It-Yourself Script Center Kit includes all the materials you need to create your own version of the TechNet Script Center, either as stand-alone Web pages, stand-alone .vbs files, or as a .chm Help file. Included in the kit are a database of all the scripts found in the TechNet Script Center Script Repository, as well as helper scripts for creating Web pages, .vbs files, and .chm files. The kit also includes instructions for using these helper scripts.

  • PowerArchiver
  • Script Debugger IDE (Shareware)

    I had a bug that I couldn't find. I used this software and immediately found that the file location was missing from a variable.

  • The Snippet Bank (Freeware)

    A simple but efficient code snippet database with search, query, search and replace, unlimited categories, list view, and export to clipboard functions.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralScript Code Pin
paddyzim25-Jan-07 14:27
paddyzim25-Jan-07 14:27 
More useful free code at ScriptCode.co.uk

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.