-
June 1st, 2015, 07:54 AM
#1
Change code to batch process
Hello all Members,
I have made this code in VB I am totally a beginner.
If you see in my code I have hardcoded absolute folderpaths and filenames.
I would like instead, You press on a button from the button you select a folder the script loops through a folder select all "xml" files. then save with same name.
See code here:
Code:
Dim analyse
Dim exactContexts
Dim subnode
Dim repeated
Dim realRepeated
Dim tmpValue
Set analyse = CreateObject("Msxml2.DOMDocument.6.0")
analyse.Load "C:\00_Projekte_temp\analyse.xml" 'HERE IS HARDCODED
Set exactContexts = analyse.SelectNodes("//inContextExact")
For i = 0 To exactContexts.Length - 1
Set subnode = exactContexts(i)
For Each att In subnode.Attributes
If att.Name = "words" Then
att.Value = "0"
Exit For
End If
Next att
Next i
Set repeated = analyse.SelectNodes("//crossFileRepeated")
For i = 0 To repeated.Length - 1
Set subnode = repeated(i)
For Each att In subnode.Attributes
If att.Name = "words" Then
tmpValue = att.Value
att.Value = "0"
Exit For
End If
Next att
Set realRepeated = subnode.NextSibling
For Each att In realRepeated.Attributes
If att.Name = "words" Then
att.Value = Val(att.Value) + Val(tmpValue)
Exit For
End If
Next att
Next i
analyse.Save "C:\00_Projekte_temp\analyse2.xml" 'HERE IS HARDCODED
Could someone help me out?
Thank you uin advance
-
June 1st, 2015, 08:11 AM
#2
Re: Change code to batch process
I got this code for the form
Code:
Public Class SdlStudioChanger
Private Sub BT_parcourir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BT_parcourir.Click
' Set Folder PATH default
FolderBrowserDialog1.SelectedPath = My.Computer.FileSystem.SpecialDirectories.MyDocuments
' Show the new folder button
FolderBrowserDialog1.ShowNewFolderButton = True
If FolderBrowserDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
' Get the full path to the file that selected by the user.
Dim dossier_selectionner As String = FolderBrowserDialog1.SelectedPath
' Displays the full path of the file selected by the user in the box (TextBox)
TB_chemin_dossier.Text = dossier_selectionner
'Displays the folder name (only) selected, the user"Subtlety, use the" IO.Path.GetFileName "on the path to a folder
'To get the name of the target folder.
'While "IO.Path.GetDirectoryName" would have shown you the folder path CONTAINING file
'Targeted by the specified path as a parameter
MsgBox("Du har valt: " & IO.Path.GetFileName(dossier_selectionner))
Else
'if the user has not selected a folder, it is a warning
MsgBox("Ingen fil vald", MsgBoxStyle.Exclamation, "Inga markerade mappar")
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|