ocran icon indicating copy to clipboard operation
ocran copied to clipboard

Path issue while executing the .exe file

Open tambero14 opened this issue 9 months ago • 4 comments

I'm successfully creating the .exe file with ocran, but when I run it, the script does it from the temporary folder, instead from the directory where the script is stored. How can I change this behaviour?

tambero14 avatar Mar 28 '25 10:03 tambero14

If you add this to the beginning of your app, it will always be in the expected directory. Hope this helps

if ENV.has_key?("OCRAN_EXECUTABLE") and not defined?(Ocran)
     $mainDirectory = File.dirname(ENV["OCRAN_EXECUTABLE"].to_s)
     Dir.chdir($mainDirectory)
   elsif not defined?(Ocran)
     $mainDirectory = __dir__
     Dir.chdir($mainDirectory)
   elsif defined?(Ocran) and not ENV.has_key?("OCRAN_EXECUTABLE")
     $mainDirectory = __dir__
     Dir.chdir($mainDirectory)
   end

I also think this behaviour is confusing, maybe we can improve it.

Largo avatar Mar 28 '25 17:03 Largo

Thanks, but I'm afraid it still doesn't work. It keeps reading from the temporary folder :(

Image

tambero14 avatar Mar 28 '25 20:03 tambero14

Okay, strange. Can you maybe share some sample code?

Also, if you could tell me the gem version, that would be helpful too.

Largo avatar Mar 28 '25 21:03 Largo

Hey! Here you have the full script. It's a simple tool that reads one or more XLSX files, takes data and generate one single .CSV file.

Lokalize_WC_generator_FINAL.zip XLS_files.zip

With the executable, I could pretty much easily run the script to the XLSX files every time I need it.

Gem version: Ocran 1.3.16

Let me know what you find out, thanks!

tambero14 avatar Mar 29 '25 17:03 tambero14