Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. Const ForReading = 1
  2. Const ForWriting = 2
  3. Dim a, b, c, D 'declaring variables
  4.  
  5. Set fs = CreateObject("Scripting.FileSystemObject")
  6. Set f = fs.GetFolder(InitialPath)
  7. Set fc = f.SubFolders
  8. InitialPath = "C:...." 'geting subfolders
  9. For Each f1 in fc
  10. Set TicFileFolder = fs.GetFolder(InitialPath & "" & f1.Name) 'geting files inside the subfolders
  11.  
  12. Set TicFiles = TicFileFolder.Files
  13. For Each TicFile in TicFiles
  14. If (UCase (left (TicFile.name, 4)) = "TIC_") then
  15. Wscript.echo "Handling file " & InitialPath & "" & f1.Name & "" & TicFile.name
  16. Set objFile_Rec = fs.OpenTextFile("C:UsersKarimYEXTVideosrelais_CODOitem_codo.txt", ForReading)
  17. Set objFile = fs.OpenTextFile(InitialPath & "" & f1.Name & "" & TicFile.name, ForReading)
  18. strNewContents = ""
  19. Do Until objFile.AtEndOfStream
  20. strLine = objFile.ReadLine
  21. strLine = objFile.ReadLine
  22. If (InStr(strLine, "|") > 0) Then 'Get fuling point number
  23. a = split(strLine,"|")
  24. b = a(4)
  25. c = a(5)
  26.  
  27. if (b = c) and Len(b) = 13 then
  28. Do Until objFile_Rec.AtEndOfStream
  29. strLine = objFile_Rec.ReadLine
  30.  
  31. If InStr(strLine, b) > 0 Then
  32. D = strLine
  33. end if
  34. end if
  35. Loop
  36. objFile_Rec.Close
  37. If InStr(strLine, b & "|" & c) > 0 Then
  38. strLine = Replace (strLine, b & "|" & c, D) 'replace data
  39. Wscript.echo "ReplacingMartnoforitem" & b
  40. End if
  41. strNewContents = strNewContents & strLine & vbCrLf
  42. 'Loop
  43. end if
  44. objFile.Close
  45. wscript.sleep (10)
  46. Set objFile = fs.OpenTextFile(InitialPath & "" & f1.Name & "" & TicFile.name, ForWriting)
  47. objFile.WriteLine strNewContents
  48. objFile.Close
  49. Loop
  50. End if
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement