Hello.
There is something I've not been able to get around to and is that when I need to use Command Line with a command that has 2 files as inputs.
The cheesy way I managed was to setup an spreadsheet with each line being a command line with hardcoded path for the files involved in each operation. Like compute distance between 2 clouds. Later in cmd, paste about 5 entries each time. Which ressults in running 5 compares in paralell, and hope for the best in terms of RAM usage...
But there must be an smart way of telling the .bat to sequentially compare file 1 in folder 1 with file2 in folder2 , and do so till the end.
This in an entry of my spreadsheet
C:\Program Files\CloudCompare\cloudcompare.exe" -SILENT -C_EXPORT_FMT LAS -O E:\LIDAR_JAPAN\MMS8\LIDAR\03_Color_Levels \ 08OE2728_PCV.las -O E:\LIDAR_JAPAN\MMS8\MMS\_00_ORIGINAL \ 08OE2728.las -c2c_dist -MAX_DIST 0.25 -FILTER_SF 0.25 0.25 -SOR 8 2
For the file name what I did whast to list all files in a folder and copy paste, so setting that up is not that hard but feels cheapo. In particular when running list manually in parts, by hand...
How do you batch process when 2 input files involved?
-
- Posts: 296
- Joined: Sat Jan 20, 2018 1:57 pm
Re: How do you batch process when 2 input files involved?
Yes, there are some examples on this forum (of commands that are applied to all files inside a folder). However, it depends on your OS.
On Windows, you can look at https://stackoverflow.com/questions/138 ... a-for-loop
On Windows, you can look at https://stackoverflow.com/questions/138 ... a-for-loop
Daniel, CloudCompare admin
-
- Posts: 296
- Joined: Sat Jan 20, 2018 1:57 pm
Re: How do you batch process when 2 input files involved?
Yes I was able to cycle trough files in ONE folder, but I was not able to do with 2 . I'll try again and if succeed post solution
-
- Posts: 296
- Joined: Sat Jan 20, 2018 1:57 pm
Re: How do you batch process when 2 input files involved?
I keep struggling with this.
I do again need to do same operation and I'm unable to build a .bat that does the job, spend morning + part of afternoon building this pseudocode...
set FileNum=0
set Compared=E:\LIDAR_JAPAN\MMS8\LIDAR\03_Color_Levels
set Reference=E:\LIDAR_JAPAN\MMS8\MMS\_00_ORIGINAL
set /a ID=1
for /f "delims=" %%G in (%Compared%) do (
set %fileList[!ID!]=%%~G
set /a ID+=1
)
for %%f in (E:\LIDAR_JAPAN\MMS8\LIDAR\03_Color_Levels) DO
set FileNum=!FileNum!+1
"C:\Program Files\CloudCompare\cloudcompare.exe" -SILENT -C_EXPORT_FMT LAS -O %Compared%\%fileList%[%FileNum%] -O %Reference%\%fileList%[%FileNum%] -c2c_dist -MAX_DIST 1 -FILTER_SF 1 1 -SOR 8 2
The idea was to build an array with the names of the files, file names are same in both folders, one is aerial lidar, other folder is vehicle lidar. Then do a loop for every file in whatever of the folders and in the loop iterate between each file in each folder so fil 1 in folder 1 compares to file 1 in folder 2 and so on till the end.
But I miserably failed, anyone with some skills please help.
I do again need to do same operation and I'm unable to build a .bat that does the job, spend morning + part of afternoon building this pseudocode...
set FileNum=0
set Compared=E:\LIDAR_JAPAN\MMS8\LIDAR\03_Color_Levels
set Reference=E:\LIDAR_JAPAN\MMS8\MMS\_00_ORIGINAL
set /a ID=1
for /f "delims=" %%G in (%Compared%) do (
set %fileList[!ID!]=%%~G
set /a ID+=1
)
for %%f in (E:\LIDAR_JAPAN\MMS8\LIDAR\03_Color_Levels) DO
set FileNum=!FileNum!+1
"C:\Program Files\CloudCompare\cloudcompare.exe" -SILENT -C_EXPORT_FMT LAS -O %Compared%\%fileList%[%FileNum%] -O %Reference%\%fileList%[%FileNum%] -c2c_dist -MAX_DIST 1 -FILTER_SF 1 1 -SOR 8 2
The idea was to build an array with the names of the files, file names are same in both folders, one is aerial lidar, other folder is vehicle lidar. Then do a loop for every file in whatever of the folders and in the loop iterate between each file in each folder so fil 1 in folder 1 compares to file 1 in folder 2 and so on till the end.
But I miserably failed, anyone with some skills please help.
-
- Posts: 296
- Joined: Sat Jan 20, 2018 1:57 pm
Re: How do you batch process when 2 input files involved?
this script does the job.
Notice it needs files in both folders have EXACT same name.
set local EnableDelayedExpansion
set Compared=E:\LIDAR_JAPAN\MMS8\LIDAR\03_Color_Levels
set Reference=E:\LIDAR_JAPAN\MMS8\MMS\_00_ORIGINAL_PCV
echo *********************** START ***********************
for %%f in ( "%Reference%"\* ) do (
echo ################################################################################################
echo %%~nxf
"C:\Program Files\CloudCompare\cloudcompare.exe" -SILENT -C_EXPORT_FMT LAS -O %Compared%\%%~nxf -O %Reference%\%%~nxf -c2c_dist -MAX_DIST 1 -FILTER_SF 1 1 -SOR 8 2)
cmd /k
EDIT: upgraded code so that it cycles based on the files in REFERENCE, this will avoid unnecesary loadings in case there are more files in the Compared folder than there are in the REFERENCE folder (which will happen for example when comparing AERIAL with GROUND scans)
Notice it needs files in both folders have EXACT same name.
set local EnableDelayedExpansion
set Compared=E:\LIDAR_JAPAN\MMS8\LIDAR\03_Color_Levels
set Reference=E:\LIDAR_JAPAN\MMS8\MMS\_00_ORIGINAL_PCV
echo *********************** START ***********************
for %%f in ( "%Reference%"\* ) do (
echo ################################################################################################
echo %%~nxf
"C:\Program Files\CloudCompare\cloudcompare.exe" -SILENT -C_EXPORT_FMT LAS -O %Compared%\%%~nxf -O %Reference%\%%~nxf -c2c_dist -MAX_DIST 1 -FILTER_SF 1 1 -SOR 8 2)
cmd /k
EDIT: upgraded code so that it cycles based on the files in REFERENCE, this will avoid unnecesary loadings in case there are more files in the Compared folder than there are in the REFERENCE folder (which will happen for example when comparing AERIAL with GROUND scans)
Re: How do you batch process when 2 input files involved?
Thanks for the feedback. I'll probably add that to the wiki.
Daniel, CloudCompare admin