REM  *****  BASIC  *****
REM https://ask.libreoffice.org/t/how-to-check-folders-name-by-macro/44665
Sub OFBwdiff
 dim sCurFileURL As String
 dim sCurFileSys As String
 dim sFolderSys As String
 dim aPaths as Variant
 dim odtName as String
 GlobalScope.BasicLibraries.LoadLibrary("Tools")
 
 sCurFileURL = ThisComponent.getURL()
 sCurFileSys = ConvertFromURL(sCurFileURL)
 aPaths=Split(sCurFileSys,"/")
REM prepare the odtDir and odtName from file path in LibreOffice: <:@<odtDir>.>
 odtDir = ""
 odtDirSep = ""
 For i = Lbound(aPaths) to Ubound(aPaths)-1
   odtDir = odtDir & odtDirSep & aPaths(i)
   odtDirSep = "/"
 Next i
 odtName = aPaths(Ubound(aPaths))
 odtName2 = FileNameoutofPath(GetFileNameWithoutExtension(ThisComponent.getLocation()))
 odtNameExt = FileNameoutofPath(ThisComponent.getLocation())
 REM aPaths(Ubound(aPaths))
 cmpnName = aPaths(Ubound(aPaths)-2)
REM odtDir is the directory where the odt file is stored. It is necessary to change to this odtDir in the called batch file.
REM odtDir is the directory where the odt file is stored. It is necessary to change to this odtDir in the called batch file.
REM odtName is the file name with .odt as extension
REM odtNameExt is the file name with extension 
REM activate the next line MsgBox for debugging this script.
REM MsgBox "Current Path : name: " & odtDir & " : " & odtName

REM call the proper script in the directory beside
REM 1. argument: A batch file to call
REM 2. argument: 1= Focus os window in standard size
REM 3. argument only one string argument for the batch separated with spaces for more effective arguments for batch.
REM 4. optional argument true then libre office waits for finish shell (sync)
REM see https://help.libreoffice.org/6.4/en-US/text/sbasic/shared/03130500.html
REM String(1,34) is the " (quotation char) ASCII = 34 = 0x22, used for surround "odtDir"
REM more as one argument separated with space, arguments maybe surround with "dir/odt"
REM Shell starts the given batch with arguments: <:@<Shell>.>

REM Shell starts the given batch with arguments: &lt;:@&lt;Shell&gt;.&gt;  <:@Shell.><::Shell.>
Shell("xterm -e " & odtDir &"/../makeScripts/genSrc_odg.sh", 1, odtName )
REM Shell("xterm")
REM Shell("xterm -hold -e ls")
End Sub
REM <:.~Shell.>
