SET variable and MKDIR in one line? Automate a process
Posted: 19 Apr 2019 08:36
Dear Forum,
I'm in need of some help with a command line I use to crop point cloud data. The software I want to use provides a very good command line mode (CloudCompare). So I wrote a little CMD one liner which is almost doing everything I want, but now I want to automate this process.
First I'm going to explain my goal, code and then my issues with it.
In an folder I have my original point cloud files "c:\originals\file_1 .. file_n". I need every file to be cropped at specific coordinates So I used a for loop to do this. I want to crop the files at over 800 positions so an automation is my goal. The cropped point clouds are going to be saved in an folder with an unique ID "c:\originals\id\". I have a list (right now in excel) with my coordinates and ID which I want to feed into the cmd line.
set the id to e.g 1 (given by my excel file) I have to run this line stand alone. Should I use /V:OFF to disable delayed environmental expansion?
make the directory for output. Problem: everything after this line is used to create folders. e.g. the for of the next line is going to be a folder, how do I prevent this?
The for loop to iterate over all files in the "originals" folder were the CMD is active (shift right click) %f is a variable for the filename
Since there are over 140 files to process I use start /w so that only one file is processed at a time
which program should be use to work with the point clouds
need to shift the date since they are geo referenced %f in use with -O is opening the file
no auto save and -CROP2D is the command for the cropping tool with 6 vertices
here the verticies for the shape of the cropping tool are defined (eg. 67 860 55 875 .... and so on)
define export format (.bin) binary format
save the cropped cloud into a given folder (needs to be created before) %id% is a unique ID of the cropped cloud %f the filename is the same as the original
Right now I change the ID and the vertices by hand but since every crop cycle takes about 30 mins to 1 hour I want to automate those two steps to use the "nights" as well .
I'm struggling to implement the the first to lines of code (set id and mkdir) to work with the rest of my code.
Additionally I don't know how to automatically read out the ID and the vertices from my excel file. I think I can save this excel file as an csv text file and somehow read out the ID and vertices. But how do I do this?
If the text file would be in the folder c:\vertices\vertices.txt (with comma separated).
The form of the text file would be ID,x1,y2,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6.
I guess i need to write a batch or .cmd file for that. But my skills are to low to do that on my own.
So In short:
Is there a way to automatically process my originals and make a batch that would crop the originals using the provided code?
Pseudocode:
I know this is very much to ask, but this would save me a really great deal of time. I hope one of you is kind enough to help me.
If there are any questions don't hesitate to ask me.
Best Tobias
I'm in need of some help with a command line I use to crop point cloud data. The software I want to use provides a very good command line mode (CloudCompare). So I wrote a little CMD one liner which is almost doing everything I want, but now I want to automate this process.
First I'm going to explain my goal, code and then my issues with it.
In an folder I have my original point cloud files "c:\originals\file_1 .. file_n". I need every file to be cropped at specific coordinates So I used a for loop to do this. I want to crop the files at over 800 positions so an automation is my goal. The cropped point clouds are going to be saved in an folder with an unique ID "c:\originals\id\". I have a list (right now in excel) with my coordinates and ID which I want to feed into the cmd line.
set the id to e.g 1 (given by my excel file) I have to run this line stand alone. Should I use /V:OFF to disable delayed environmental expansion?
Code: Select all
set id=*
Code: Select all
mkdir %id%
Code: Select all
for %f in (./*) do start /w ""
which program should be use to work with the point clouds
Code: Select all
"C:\Program Files\CloudCompare\CloudCompare.exe"
Code: Select all
-O -GLOBAL_SHIFT -312600 -5693000 0 %f
Code: Select all
-AUTO_SAVE OFF -CROP2D z 6
Code: Select all
x1 y2 x2 y2 x3 y3 x4 y4 x5 y5 x6 y6
Code: Select all
-C_EXPORT_FMT BIN
Code: Select all
-SAVE_CLOUDS FILE: "C:\originals\%id%\%f"
I'm struggling to implement the the first to lines of code (set id and mkdir) to work with the rest of my code.
Additionally I don't know how to automatically read out the ID and the vertices from my excel file. I think I can save this excel file as an csv text file and somehow read out the ID and vertices. But how do I do this?
If the text file would be in the folder c:\vertices\vertices.txt (with comma separated).
The form of the text file would be ID,x1,y2,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6.
I guess i need to write a batch or .cmd file for that. But my skills are to low to do that on my own.
So In short:
Is there a way to automatically process my originals and make a batch that would crop the originals using the provided code?
Pseudocode:
Code: Select all
1. read the first ID and vertices from file and store them in variables
2. make output directory using the ID as folder name
3. crop all originals using the code lines above and save them in the right folder
4. read the next ID and vertices
5. make new directory with ID
6. crop .... and so on
If there are any questions don't hesitate to ask me.
Best Tobias