Command line; loading multiple files from a list file

To post any request/idea for new functionalities
Post Reply
jukka.alander
Posts: 10
Joined: Fri Nov 30, 2018 12:55 pm

Command line; loading multiple files from a list file

Post by jukka.alander »

Hello,

Would it be possible to have a command line command to load multiple input files that are listed in a text file (just a filename per row) ?

Br,
Jukka
WargodHernandez
Posts: 187
Joined: Tue Mar 05, 2019 3:59 pm

Re: Command line; loading multiple files from a list file

Post by WargodHernandez »

you can, there are a number of different ways to do it here is one example in a .bat on windows. this is a script I use to ping a bunch of ip address in a standalone text file

Code: Select all

@echo off
setlocal enabledelayedexpansion

set OUTPUT_FILE=.\result.txt
>nul copy nul %OUTPUT_FILE%
for /f "tokens=1,*" %%i in (.\IPAddressList.txt) do (
    set SERVER_ADDRESS=ADDRESS N/A
    for /f "tokens=1,2,3" %%x in ('ping -n 1 %%i ^&^& echo SERVER_IS_UP') do (
        if %%x==Pinging set SERVER_ADDRESS=%%y
        if %%x==Reply set SERVER_ADDRESS=%%z
        if %%x==SERVER_IS_UP (set SERVER_STATE=UP) else (set SERVER_STATE=DOWN)
    )
    echo %%j [!SERVER_ADDRESS::=!] is !SERVER_STATE! >>%OUTPUT_FILE%
    echo %%j [!SERVER_ADDRESS::=!] is !SERVER_STATE!
)
and here is a couple lines of that file with IPaddresses and server names scrubbed

Code: Select all

192.168.1.1 ServerName_1
192.168.1.2 Servername_2
The problem with this method in my mind is it is only loading one file at a time and loading CloudCompare and unloading it after each iteration
There are other ways to just have it group up the first item into a concated string and do all at once but I don't have any readily available demos, but I have done something like it with powershell before.

actually just search google for how to ping ip addresses listed in a standalone file and you will get examples for Powershell, batch, bash, just about any way you would want, they aren't specific to CloudCompare but there are a lot more people who need to ping then use CloudCompare
theadib
Posts: 7
Joined: Wed Oct 21, 2020 8:07 pm

Re: Command line; loading multiple files from a list file

Post by theadib »

This is possible with the qJsonRPCPlugin.

There is some example in the test directory of that plugin folder.
The example uses some simple Python code

i.e.
{"jsonrpc": "2.0", "method": "open", "params": {"filename": "/home/adib/Dokumente/teapot.ply"}, "id": 4}
this will also trigger the fileopen dialogue for setting options
or more specific
{"jsonrpc": "2.0", "method": "open", "params": {"filename": "/home/adib/Dokumente/teapot.ply", "filter":"PLY mesh (*.ply)", "silent":true, "name":"testpod", "parent":"one/two/three"}, "id": 4}
which sets some options and suppress the open dialogue

HTH, Adib.
--
dreiländereck
Posts: 15
Joined: Sun Feb 28, 2021 9:06 am

Re: Command line; loading multiple files from a list file

Post by dreiländereck »

We did it without a file list. All files are in folders and have the same ending/ file type.

Code: Select all


for %%f in (f:\LAS\Abschnitt_1_FR_1\*.las) DO "C:\Program Files\CloudCompare\cloudcompare.exe" -SILENT -O -GLOBAL_SHIFT AUTO %%f -C_EXPORT_FMT LAS -NO_TIMESTAMP -SS SPATIAL 0.01 
for %%f in (f:\LAS\Abschnitt_1_FR_2\*.las) DO "C:\Program Files\CloudCompare\cloudcompare.exe" -SILENT -O -GLOBAL_SHIFT AUTO %%f -C_EXPORT_FMT LAS -NO_TIMESTAMP -SS SPATIAL 0.01 

It took a while for a non windows script experienced user, but works smooth and perfectly.
Regards Sebastian
jukka.alander
Posts: 10
Joined: Fri Nov 30, 2018 12:55 pm

Re: Command line; loading multiple files from a list file

Post by jukka.alander »

Thanks for comments! I should have been more spesific; I can already batch process multiple files one by one, but what I'm looking for is a simple way to load 1...n E57 files in a one command ( to one instance of CC) and merge them all together, subsample and export one file.

It can be done by producing a command line like this:
-O file1.e57 -O file2.e57 ....

..but I'd rather open just point to one file that has a path to each file per line.
dreiländereck
Posts: 15
Joined: Sun Feb 28, 2021 9:06 am

Re: Command line; loading multiple files from a list file

Post by dreiländereck »

jukka.alander wrote: Mon Mar 15, 2021 1:54 pm Thanks for comments! I should have been more spesific; I can already batch process multiple files one by one, but what I'm looking for is a simple way to load 1...n E57 files in a one command ( to one instance of CC) and merge them all together, subsample and export one file.

It can be done by producing a command line like this:
-O file1.e57 -O file2.e57 ....

..but I'd rather open just point to one file that has a path to each file per line.
Therefore the

Code: Select all

-MERGE_CLOUDS
command has to be used (at last command in the commands chain). See the wiki for details.

I think, at the moment there is no 'out of the box' solution for your issue. You can fill in an enhancement issue on GitHub and maybe a programer will take it. For my less C++ knowledge this is to far away at the moment.

Have you tried to grab the filenames with a skript or program like TotalCommander to insert the -O commands into a batch file?
Regards Sebastian
jukka.alander
Posts: 10
Joined: Fri Nov 30, 2018 12:55 pm

Re: Command line; loading multiple files from a list file

Post by jukka.alander »

Ok here's finally a windows batch script that loads all e57 files in the current folder, merges, subsamples and saves out to one e57. I might later on update it to read the filelist.
____________________
SETLOCAL EnableDelayedExpansion
cd /D %~dp0
set _filelist=
for /f "delims=|" %%f in ('dir /b "*.e57"') do (
set "_filelist=!_filelist! -O %%f"
)
set _filelist=%_filelist:,,=%
rem echo %_filelist% > filelist.txt
"C:\Program Files\CloudCompare\CloudCompare.exe" -silent %_filelist% -LOG_FILE .\log.txt -AUTO_SAVE off -MERGE_CLOUDS -SS SPATIAL 0.02 -C_EXPORT_FMT E57 -SAVE_CLOUDS
pause
____________________
PablerasBCN
Posts: 297
Joined: Sat Jan 20, 2018 1:57 pm

Re: Command line; loading multiple files from a list file

Post by PablerasBCN »

@dreiländereck

thank you so much for this .bat its pure gold and has streamlined my process allowing to leave pc overnight
Post Reply