Solved

How can you create a list from a folders contents that is auto updated?

Posted on 2009-07-07
6
187 Views
Last Modified: 2012-05-07
I need to have a list of the contents of a directory  automatically updated in an Access database  is there anyway to do this?

If not, does anyone have any other suggestions on how I may be able to accomplish that

0
Comment
Question by:PCoulter
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 5

Assisted Solution

by:mredfelix
mredfelix earned 50 total points
ID: 24799493
i would read the files output them to a csv file and run it as a schedule task.

or you can create a script to monior the change in the folder
/* Create the FileSystemObject */
fso = new ActiveXObject("Scripting.FileSystemObject");
 
/* Point the Object to a specific folder */
fsofolder = fso.GetFolder("C:\\temp");
 
/* get a collection of the files contained in that folder */
colFiles  = fsofolder.Files;
 
/* Create an Enumerator so that we can move through the collection */
fc = new Enumerator( colFiles );
 
/* Create a variable to store an output message in */
var msg = "";
 
/* Loop through the Enumerator and add each item to our variable */
for (; !fc.atEnd(); fc.moveNext() ){
 msg += fc.item() + "\n";
}
 
/* Show the user the results */
WScript.Echo( msg );

Open in new window

0
 
LVL 5

Accepted Solution

by:
Adam Ray earned 450 total points
ID: 24809961
mredfelix, what language is that in?  I.E.  I don't do any scripting in Access, so I don't know if that will run or not, but I do know it's won't work as a stand-alone vbscript (.vbs) file.

The code below (with a bit of modification) is from http://www.go4expert.com/forums/showthread.php?t=927
You can just drop it in a .vbs and it will create a .txt file with all of the files in the directory, one entry per line.

There are lots of options on things you can include in the listing.  Listing files in subdirectories is quite possible, but it does get more complicated.  Modifing the script on this page to output to a file rather than to console will do the trick: http://www.microsoft.com/technet/scriptcenter/resources/qanda/oct04/hey1020.mspx

Once you have the file you can then import it into Access.

But if you want something that is completely automated you can use and ODBC connection from the VBscript and write the information directly to the Access database.  There should be plenty of examples of that out there if you search for it.  


On Error Resume Next
  Dim fso, folder, files, NewsFile,sFolder
 
  Set fso = CreateObject("Scripting.FileSystemObject")
  sFolder = "C:\temp"
  Set NewFile = fso.CreateTextFile(sFolder&"\FileList.txt", True)
  Set folder = fso.GetFolder(sFolder)
  Set files = folder.Files
 
  For each folderIdx In files
    NewFile.WriteLine(folderIdx.Name)
  Next
  NewFile.Close

Open in new window

0
 
LVL 5

Expert Comment

by:mredfelix
ID: 24811255
it is a vbs script and its not a complete script...
0
Simple, centralized multimedia control

Watch and learn to see how ATEN provided an easy and effective way for three jointly-owned pubs to control the 60 televisions located across their three venues utilizing the ATEN Control System, Modular Matrix Switch and HDBaseT extenders.

 

Author Comment

by:PCoulter
ID: 24813341
I heard somewhere that I may be able to create a file from DOS to place in the folder that would automatically update any changes made within the folder.... anyone know anything about this?

I am unfamiliar with the where I should place the scripts mentioned above...
0
 
LVL 5

Expert Comment

by:mredfelix
ID: 24818015
you can run it as a schedual task anywhere

its the  sFolder  which is the key as that says what folder it is

0
 
LVL 5

Assisted Solution

by:Adam Ray
Adam Ray earned 450 total points
ID: 24818473
The Windows file system does not have the ability to send out any type of alert when a folder changes.  However, you can make a script (or use an existing application someone else wrote) that runs in the background all the time and monitors to folder for changes every X seconds.  There are examples of this on Microsoft's Script Center, try searching for "Hey Scripting Guy"  This solution is almost certainly the type of thing that you were thinking about as a "file from DOS," since many of these solutions run from the command prompt (i.e. DOS window.)

If you want something like that, as opposed the above scripts possibilities are more intended to be run via a scheduled task from every X _minutes_ to every other week (or however long.)  But just to be sure you don't get over lapping results I wouldn't run the scheduled task flavor more than frequently than ever 10 minutes.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Greetings, Experts! First let me state that this website is top notch. I thoroughly enjoy the community that is shared here; those seeking help and those willing to sacrifice their time to help. It is fantastic. I am writing this article at th…
Trying to figure out group policy inheritance and which settings apply where can be a chore.  Here's a very simple summary I've written which might help.  Keep in mind, this is just a high-level conceptual overview where I try to avoid getting bogge…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question