How to take path from batch in LyX2.3.2?

by Alex_Morfeo   Last Updated May 22, 2019 08:23 AM

I'm using LyX in Windows 10 and searching to display the path where the file.tex is placed, this file is supposed to be placed in different and used from different users. I try to explain what I'm searching to do: I have this file.tex where i want to put the complete path of where it's placed, for example C:\users\name\latex file\file.tex. So I tried placing in "LaTeX Preamble":


\immediate\write18{batch 'dir' > temp.tex}

To make possible the use of external programs I have put --shell-escape going on:

Tools->Preferences..->File Handling->Converts

And in "LaTeX (pdflatex) -> PDF (pdflatex)" writing in Converter pdflatex --shell-escape $$i. How you can see I'm using a temp file where put the output of the batch's command. So I expect, after the launch of file.tex, to see in the temp.tex this:
C:\users\name\latex file\file.tex

I know that LaTeX don't like characters like '\' so I wrote a script.bat to replace '\' with '-' (I know it dont look really nice to see):
Powershell -NoProfile -ExecutionPolicy Bypass -Command "(Get-Content temp.tex -ReadCount 0) -replace [regex]::Escape('\'),'-' | Set-Content temp.tex"

I tried to execute this file from LaTeX writing:

\immediate\write18{batch script.bat}



After that in my temp.tex I expect something like:
C:-users-name-latex file-file.tex
To diplay it on the pdf of file.tex i put in a box with TEX-code(CTRL+L):


This solution doesnt work. I readed a lot of other questions here in stackexchange and other forums but no one work... Surely there is something that I'm making wrong but I dont know what. I hope someone can help me, thanks.

Related Questions

Can't execute jar from directory with umlaut

Updated December 14, 2018 17:23 PM

error when using tikzpicture with moodle package

Updated November 13, 2018 20:23 PM