ghudson
Registered User.
- Local time
- Today, 01:37
- Joined
- Jun 8, 2002
- Messages
- 6,194
I have tried searching on this quest but I can not find exactly what I need. If I missed a post please reply with the link and I will go from there.
I need to delete the oldest files in a directory and keep the newest file for each file type. I have code to delete files but the twist is I need to keep the newest file for each type of file. The type is determined by the file name prefix, not the file extension and I will have six different types of files. The files are automatically downloaded from a system. Each file type has a specific file name prefix, the system assigns the process number to the file name type which is the series of six numbers just before the .xls file extension. Here is an example of the file in the directory...
XYZ_123_A-258743.xls [file date/time = 07/08/2005 13:42:21]
XYZ_123_A-345782.xls [file date/time = 07/08/2005 09:24:36] *
XYZ_123_A-154952.xls [file date/time = 07/08/2005 11:12:45] *
ABC_987_Z-654785.xls [file date/time = 07/08/2005 08:36:14] *
ABC_987_Z-742589.xls [file date/time = 07/08/2005 10:05:42] *
ABC_987_Z-875123.xls [file date/time = 07/08/2005 14:30:54]
Based on the above example, I would need the four files with an asterisks * deleted so that the following two files are left in the directory because they have the newest modified date/time stamp.
XYZ_123_A-258743.xls [file date/time = 07/08/2005 13:42:21]
ABC_987_Z-875123.xls [file date/time = 07/08/2005 14:30:54]
Does anybody already have a rountine that will accomplish what I want? Thanks in advance for your help!
I need to delete the oldest files in a directory and keep the newest file for each file type. I have code to delete files but the twist is I need to keep the newest file for each type of file. The type is determined by the file name prefix, not the file extension and I will have six different types of files. The files are automatically downloaded from a system. Each file type has a specific file name prefix, the system assigns the process number to the file name type which is the series of six numbers just before the .xls file extension. Here is an example of the file in the directory...
XYZ_123_A-258743.xls [file date/time = 07/08/2005 13:42:21]
XYZ_123_A-345782.xls [file date/time = 07/08/2005 09:24:36] *
XYZ_123_A-154952.xls [file date/time = 07/08/2005 11:12:45] *
ABC_987_Z-654785.xls [file date/time = 07/08/2005 08:36:14] *
ABC_987_Z-742589.xls [file date/time = 07/08/2005 10:05:42] *
ABC_987_Z-875123.xls [file date/time = 07/08/2005 14:30:54]
Based on the above example, I would need the four files with an asterisks * deleted so that the following two files are left in the directory because they have the newest modified date/time stamp.
XYZ_123_A-258743.xls [file date/time = 07/08/2005 13:42:21]
ABC_987_Z-875123.xls [file date/time = 07/08/2005 14:30:54]
Does anybody already have a rountine that will accomplish what I want? Thanks in advance for your help!