Find File Create Date (1 Viewer)

GBalcom

Much to learn!
Local time
Today, 07:35
Joined
Jun 7, 2012
Messages
459
I'll try to make this short. We have a CNC Machine (Windows-based) on our shop floor that we send files to from the office. These files are used once, to run the program, then we need to delete them periodically, as searching for the right file takes too long otherwise. I want to create a small app that would automatically run from our server, to look into that machine, find the file creation date and delete the old files.

What pitfalls should I consider for this approach? Is it worth writing to a Log table during this process? Is there a way to filter by date to quickly select the correct files, or do I need to loop through them one by one in a recordset?
 

plog

Banishment Pending
Local time
Today, 09:35
Joined
May 11, 2011
Messages
11,638
I'm always leery of deleting things. I would lean towards moving them somewhere out of the way, unless of course your deletion parameter is like over a year so you can verify for sure that the file will never be needed again.

From a technical standpoint there's no reason to make this a whole app, no need for recordsets even. This, including writing to a log file, can be done in 5 lines of a batch file.

Google: 'find oldest file in directory of windows in batch file'

That's one line of code there, then 1 more to log them, and 1 more to delete them.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 09:35
Joined
Feb 28, 2001
Messages
27,142
Pitfalls? I suppose there might be a few. The question is, does your CNC software do anything to the files so you can tell you HAVE run it? I will presume that you persist in using Access to do this, though a batch file or VBS type of script might work just as well.

IF you are staying with Access:

#1 - The CNC machine HAS to use Windows File Sharing. Since you are already sending it files, the question is whether you do that via Windows File Sharing (SMB protocol) or a File Transfer Protocol (FTP protocol)? For Access to do this from another system, you need to have SMB enabled.

#2 - Learn to use the File System Object, which would then let you initiate directory scans. You can give the FSO a path to examine and then look at the collection of files that it discovered during that examination. For each file, you can look at its properties to include age (creation date).

#3 - You will need to look at the permissions on the folder where this is being done because you WILL need to elevate the permissions on the account that will be running this operation. If the CNC machine is actually a member of your local domain, you COULD mark everything with some sort of group identifier so that the permission to do what you need to do could be derived from the group. (This would govern the original download of the file, too, if you get down to this level of security.)

The question of "age" becomes an issue if the CNC software doesn't mark the file in some way after using it. How old are you considering as "too old"? (That is a RHETORICAL question to answer for yourself, not for me.)
 

Users who are viewing this thread

Top Bottom