Page 1 of 1
Using spaces in the command line mode
Posted: Fri Jan 27, 2023 4:34 pm
by klift
Hello,
I am currently working on writing a command line script to convert a batch of .laz files to .e57 format and it seems to work in most of cases.
Code: Select all
set local EnableDelayedExpansion
REM specify the directory with the .laz files for the format change
set Files2Convert="D:\in"
REM specifying the directory where the converted files must be saved
set Output="D:\out"
REM cycling through all files within the Files2Convert directory and applying "Convert" function
for %%f in ( "%Files2Convert%"\* ) do (call :Convert "%%f")
pause
:Convert
REM extracting the filename with the file format
set filename="%~nx1"
REM removing all spaces from the name
set filename=%filename: =%
REM creating a saving path and changing the format
set savepath="%Output:~1,-1%\%filename:~1,-1%"
set savepath=%savepath:.laz=.e57%
REM calling the cloudcompare executable
"C:\Program Files\CloudCompare\cloudcompare.exe" -SILENT -AUTO_SAVE OFF -O %1 -C_EXPORT_FMT E57 -SAVE_CLOUDS FILE %savepath%
:End
The problem I have is related to the directories with spaces in their names. Due to the spaces, CloudCompare assumes that there are multiple clouds to save and it causes an error. Is there a way to handle the spaces in specified paths except for just not using those paths? And is there a better way to convert multiple .laz files to .e57?
Re: Using spaces in the command line mode
Posted: Sat Jan 28, 2023 8:28 am
by daniel
Re: Using spaces in the command line mode
Posted: Sat Jan 28, 2023 12:17 pm
by klift
Thank you, I have checked the link. It indeed solves the problem of just having paths with spaces in cmd. I had this problem initially as well and I also solved it by using quotes. However, it doesn't help when the command -SAVE_CLOUDS is used. I use it along with the option FILE in order to save the output in a different specified directory.
Perhaps, it is not the intended use of this option, since CloudCompare wiki states that this option allows the user to specify the output filename(s) of the clouds (FILE "file1.xxx file2.yyy ...") and nothing is said about saving files in different directories. Although, if a path is specified along with the filename, it saves the output in a different directory. It will work, given that the output path doesn't have any spaces, otherwise CloudCompare will assume it is a separator, which separates two different filenames for two different clouds (just like in the example FILE "file1.xxx file2.yyy ..."), which will cause an error. Is there a way to overcome it or currently the only solution is to use paths without spaces?
Re: Using spaces in the command line mode
Posted: Wed Feb 08, 2023 7:13 am
by daniel
Ah, indeed, we may have an issue differentiating paths with spaces and arguments... We'll have to take care of that globally I believe. For now you'll have to use paths without spaces, but it should be fixed soon (hopefully).
Re: Using spaces in the command line mode
Posted: Sun Feb 12, 2023 9:36 pm
by daniel
Ok, this should be fixed now (with the 2.13.alpha version from today).
You can use either double or single quotes for filename (or scalar field names) with spaces.
Re: Using spaces in the command line mode
Posted: Thu May 11, 2023 8:12 am
by SeaTea
daniel wrote: ↑Sun Feb 12, 2023 9:36 pm
Ok, this should be fixed now (with the 2.13.alpha version from today).
You can use either double or single quotes for filename (or scalar field names) with spaces.
This does not appear to be working. I'm using the latest 2.13 Alpha version (installed last week). The files are dragged and dropped onto the batch file.
I have a simple command line batch that takes the input file and applies a SOR filter before saving it as the original filename with an appended string at the end. This works perfectly for all filenames without spaces but not for any name containing a space. It throws an error with the number of clouds it wants to save is relative to the number of spaces in the filename. eg. Invalid parameter: specified 3 file names, but there are 1 clouds.
The bat file looks like this
Code: Select all
pushd "%~dp1"
"C:\Program Files\CloudCompare\cloudcompare.exe" -O "%~1" -AUTO_SAVE OFF -SOR 8 2 -C_EXPORT_FMT LAS -EXT LAZ -SAVE_CLOUDS FILE "%~n1_Only_SOR%~x1"
popd
Re: Using spaces in the command line mode
Posted: Sun May 14, 2023 12:13 pm
by daniel
Your script works well on my side (with the latest 2.13.alpha version).
Could it be that you have space characters or other special characters in the filename?
What does the command look like when you drop the file on your batch file?
On my side I have:
Code: Select all
"C:\Program Files\CloudCompare\cloudcompare.exe" -O "F:\Data\LAS\u4625640_12-06-23_allclasses_fence.las" -AUTO_SAVE OFF -SOR 8 2 -C_EXPORT_FMT LAS -EXT LAZ -SAVE_CLOUDS FILE "u4625640_12-06-23_allclasses_fence_Only_SOR.las"
Re: Using spaces in the command line mode
Posted: Mon May 15, 2023 6:40 am
by SeaTea
daniel wrote: ↑Sun May 14, 2023 12:13 pm
Your script works well on my side (with the latest 2.13.alpha version).
Could it be that you have space characters or other special characters in the filename?
What does the command look like when you drop the file on your batch file?
On my side I have:
Code: Select all
"C:\Program Files\CloudCompare\cloudcompare.exe" -O "F:\Data\LAS\u4625640_12-06-23_allclasses_fence.las" -AUTO_SAVE OFF -SOR 8 2 -C_EXPORT_FMT LAS -EXT LAZ -SAVE_CLOUDS FILE "u4625640_12-06-23_allclasses_fence_Only_SOR.las"
Hi Daniel. Yes, as I mentioned in my previous post, this does work for filenames that do not have any spaces in them. If the filename has any spaces, it returns an error. I possibly misread but I thought 2.1.3 Alpha had fixed it so that it would allow spaces in the file name. I have the output filename inside inverted commas "" so that it should treat it as a complete string but CloudCompare won't write the filename out if there are spaces.
Re: Using spaces in the command line mode
Posted: Tue May 16, 2023 7:29 am
by SeaTea
SeaTea wrote: ↑Mon May 15, 2023 6:40 am
daniel wrote: ↑Sun May 14, 2023 12:13 pm
Your script works well on my side (with the latest 2.13.alpha version).
Could it be that you have space characters or other special characters in the filename?
What does the command look like when you drop the file on your batch file?
On my side I have:
Code: Select all
"C:\Program Files\CloudCompare\cloudcompare.exe" -O "F:\Data\LAS\u4625640_12-06-23_allclasses_fence.las" -AUTO_SAVE OFF -SOR 8 2 -C_EXPORT_FMT LAS -EXT LAZ -SAVE_CLOUDS FILE "u4625640_12-06-23_allclasses_fence_Only_SOR.las"
Hi Daniel. Yes, as I mentioned in my previous post, this does work for filenames that do not have any spaces in them. If the filename has any spaces, it returns an error. I possibly misread but I thought 2.1.3 Alpha had fixed it so that it would allow spaces in the file name. I have the output filename inside inverted commas "" so that it should treat it as a complete string but CloudCompare won't write the filename out if there are spaces.
OK, I managed to fix the issue by putting the output string inside single and then double quotation marks ' " (with no space).
'"%~n1_SOR%~x1"'
Code: Select all
pushd "%~dp1"
"C:\Program Files\CloudCompare\cloudcompare.exe" -O "%~1" -AUTO_SAVE OFF -SET_ACTIVE_SF Range -FILTER_SF 1.5 35 -SET_ACTIVE_SF Intensity -FILTER_SF 1 255 -SOR 8 2 -C_EXPORT_FMT LAS -EXT LAZ -SAVE_CLOUDS FILE '"%~n1_SOR%~x1"'
popd
Re: Using spaces in the command line mode
Posted: Fri Dec 15, 2023 11:08 am
by Theresa76
SeaTea wrote: ↑Mon May 15, 2023 6:40 am
daniel wrote: ↑Sun May 14, 2023 12:13 pm
Your script works well on my side (with the latest 2.13.alpha version).
Could it be that you have space characters or other special characters in the filename?
What does the command look like when you drop the file on your batch file?
On my side I have:
Code: Select all
"C:\Program Files\CloudCompare\cloudcompare.exe" -O "F:\Data\LAS\u4625640_12-06-23_allclasses_fence.las" -AUTO_SAVE OFF -SOR 8 2 -C_EXPORT_FMT LAS -EXT LAZ -SAVE_CLOUDS FILE "u4625640_12-06-23_allclasses_fence_Only_SOR.las"
Hi Daniel. Yes, as I mentioned in my previous post, this does work for filenames that do not have any spaces in them. If the filename has any spaces, it returns an error. I possibly misread but I thought 2.1.3 Alpha had fixed it so that it would allow spaces in the file name. I have the output filename inside inverted commas "" so that it should treat it as a complete string but CloudCompare won't write the filename out if there are spaces.
Thanks for the information!