I currently have the attached script working as a .vbs file on my desktop, but I didn't write it and I don't have any experience in this kind of thing, which is causing me a problem as I need to modify it to do what I need.
Basically, I need to include an ActiveX script in a dts package that I'm working on that will check a folder to make sure there is a file in there (which will always start with the same string but will end with a random one). There should only ever be one file in there. Once it's checked that it is there it needs to somehow make a note of the original filename. Ideally this would be stored in a database table as I'll need to reference it later. Then it needs to rename the file to 'feed.in'
Can anyone help with modifying this script to do what I need, or possibly writing a new one that will do the job??
Please note that this is just a script I found elsewhere on EE so the fact that it renames all of the files in a directory doesn't relate to what I actually need it to do, it's just that this was the closest I could get to what I wanted!
Many thanks in advance.
Const folder = "C:\documents and settings\swd\my documents\testfolder"
Const logfile = "logfile.log"
If folder = "" OR logfile = "" Then
Dim fso: Set fso = CreateObject("Scripting.FileSystemObject")
Set objfolder = fso.GetFolder(folder)
If fso.FileExists(folder & "\" & logfile) Then
fso.DeleteFile(folder & "\" & logfile)
Set objlog = fso.CreateTextFile(folder & "\" & logfile, true)
Set objfiles = folderobj.files
Set objsubfolders = folderobj.subfolders
for each subfolder in objsubfolders
i = 1
for each file in objfiles
if not file.Name = logfile Then
objlog.WriteLine("[" & Now() & "] Renaming File " & file.Name & " to " & folderobj.Path & "\" & folderobj.Name & i & "." & fso.GetExtensionName(file.Name))
file.Move folderobj.Path & "\" & folderobj.Name & i & "." & fso.GetExtensionName(file.Name)
i = i+1