DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

VBS Script to open and modify all DAT files in a folder and its subfolders

Hi all,

 

I use VBS scripts to modify channel names in DAT files. This works great as long as all DAT files are in the same folder. Now I was asked to to something similar, but this time, the DAT files are in different subfolders (or sub-sub-subfolders). Only one dat file per subfolder.

 

How can I modify my script to make it  look for all DAT files in all subfolders?

 

here is my code:

 

Call DataDelAll(TRUE) '--Datenbereich löschen
Call FILENAMEGET("ANY", "FileRead","*.dat","Datensatz (*.DAT), *.DAT",,, "Datensatz auswählen") '--Importmodul muß auf ANY stehen
If (DlgState = "IDCancel") Then ' Dialog abgebrochen
  AutoQuit("Abbruch durch Benutzer!")
End If
 
Set obj = fso.GetFolder(FileDlgDir)
 
 
ExportFileNo = 0
For each oFiles in obj.Files
  If fso.GetExtensionName(oFiles.Name) = "dat" or fso.GetExtensionName(oFiles.Name) = "DAT" Then
    
    Call DataDelAll(TRUE)
    Call DataFileLoad(FileDlgDir & "\" & oFiles.Name,"DAT")
    
'Berechnungen
Set ChnResult = ChnLinScale("[1]/Channel_left", "[1]/Channel_left", 1.0673404, 0) 'Umrechnung Empfindlichkeit 
Set ChnResult = ChnLinScale("[1]/Channel_right", "[1]/Channel_right", 1.0673404, 0) 
  
  strDateiname = RootPropValGet("name")
  strDateiname = strDateiname &"_korr"
       
  Call DataFileSave(FileDlgDir &"\"& strDateiname, "DD8x", True)    
    
  End If
 
Next
0 Kudos
Message 1 of 1
(44 Views)