I am trying to run .mlx scripts using Meshlabserver through the Git Bash console on Windows. I have the .mlx scripts in a single folder, and I have a file called script_list.txt
that contains a list of all the scripts, which looks something like that:
C:/My_Work_Files/Batch_resize_surfaces_test/resize_meshlab_5.mlx
C:/My_Work_Files/Batch_resize_surfaces_test/resize_meshlab_52.mlx
C:/My_Work_Files/Batch_resize_surfaces_test/resize_meshlab_54.mlx
C:/My_Work_Files/Batch_resize_surfaces_test/resize_meshlab_56.mlx
...
For what I want to do, I need to select a random .mlx script from the list and then pass it to Meshlabserver while calling it from Bash. For that purpose I have this code:
mapfile -t myArray < "C:\My_Work_Files\Batch_resize_surfaces_test\script_list.txt"
num=$(shuf -i 1-13 -n 1)
Script=${myArray[$num]}
The idea is that this code will be inside a loop and each time $num
will be different which would fetch a random .mlx script from the list.
I call Meshlabserver using this code:
"C:\Program Files\VCG\MeshLab\meshlabserver.exe" -i "$file" -s $Script -o "${file%.*}_deci.ply" -m vn
However, it is telling me that $Script
does not exist. When I manually assign the .mlx file to $Script
like so:
Script="C:/My_Work_Files/Batch_resize_surfaces_test/resize_meshlab_5.mlx"
Meshlabserver finds the file and it runs without any issues. I cannot for the life of me understand what is the difference between fetching the filename and its path from a .txt file and passing it to a variable, and manually passing the same string to a variable. When I echo the two strings in the console they look identical. It is clearly something to do with Bash, but I can't figure it out.
Edit: for clarification, the complete code is this:
mapfile -t myArray < "C:\My_Work_Files\Batch_resize_surfaces_test\script_list.txt"
num=$(shuf -i 1-13 -n 1)
Script=${myArray[$num]}
"C:\Program Files\VCG\MeshLab\meshlabserver.exe" -i "$file" -s $Script -o "${file%.*}_deci.ply" -m vn