How to iterate over an exe file that takes arguments in cmd - c++

There is a program that accepts images containing license plates as arguments.
This program extracts only the license plate itself, letter and number image from the image received as an argument.
How to use this program is as follows.
C:\Users\gksql\Desktop\PlateRec>PlateRecog_saveDigits_Location someimage.jpg
This will create one image_Plate.jpg file that contains the license plate itself and several image_Digits_ (number) .jpg files that contain numbers or characters.
The problem is that the execution command itself is quite long, and there are at least a few thousand images.
That's why I want to run this PlateRecog_saveDigits_Location.exe file for all images containing license plates in any folder.
As a matter of fact, I can not change the source of the PlateRecog_saveDigits_Location file at this time.
I want to know how to iterate through all the images in a window.
Thank you for your wisdom.

Post is tagged c++, bash, shell...
looks like you want to loop through a list of files, calling the same executable if i understand correctly. Here are some good posts to get you going.
Loop through files in directory c++:
How do you iterate through every file/directory recursively in standard C++?
Launching an executable from within a c++ project:
How do I open an .exe from another C++ .exe?
Iterating through files in directory (bash):
How to iterate over files in a directory with Bash?
Iterating through files in directory (powershell):
Loop through files in a directory using PowerShell

Related

Automate dekstop screening with Python

I am trying to make a program that could automatically scan the images or texts on a user's desktop and then convert it to a .txt file for text analysis.
So far I have found source codes to convert PDF and HTML into .txt. However I would like to make my program automatically scan the desktop screen at certain time intervals rather than manually inputting the source such as:
$pdf2txt.py samples/simple1.pdf
I don't know where to start so any suggestion will be appreciated.
First of all, the desktop is just a location in the file directory like:
C:\Users\Kirsteen\Desktop
So the next step would be to search through this directory for the types of files you are interested in. You'd be aiming to generate a list of valid file names that need to be converted. This Q/A might help you.
Once the files have been found run those converting scripts you have. To repeat this automatically put all of this in a loop and add a delay so that it runs once an hour/week.
To tidy things up, think about running this process in the background and making sure the program doesn't convert the files more than once if they haven't changed.

Testing with .in files without changing code

I'm doing some programming problems from the previous year competition and in the problem text there is only one case, which is simple so I can just rewrite it when testing.
Now, I also have a folder with a bunch of .in and .out files, in format '01.in, 01.out, 02.in, 02.out, etc'.
Is there a way to somehow take one of those .in files and automatically use all the lines of it as input without making changes inside my program but rather doing it directly from the command line?
Thanks
Assuming linux:
cat *.in | yourprogram
On Windows you'd use type instead of cat.
I assume your program takes in and processes the agruments (argv[]) passed to it already. If this is the case, one way could be to write a simple wrapper program (in Python for example) which opens the required .in files, reads the lines in it and invokes your C++ program by passing the required lines as input to them.
Then you can execute this python program or make changes to it as required.

how to get number of files in a directory using c++ program on windows commands

I have some N number of images(pictures) in a file.I want to get number images in that file and store that number to another file. I want all these to be done through C++ code on Windows
using windows commands with system();
Can any one Help.
Maybe you can try a variation of this in which you'll count the number of files instead of printing the names.

Specific Folder save & read

I'm developing a game for mi Advance Algorithm class, but I'm having a problem with the read and save. I want to save the "fields" on a .txt file but on a specific folder in my solution. I want to create 1 file per field, and I want to read all the .txt files on that specific folder when I load the solution. The user must not send any address for saving or reading, that must be done by default by the program. I'm actually using this :
FILE* arch =fopen("Tableros.tbl","wt");
if(arch==NULL)return;
Same thing for reading. But I can only read one file, and I want to detect or read all .txt on that specific folder. Any ideas or functions that can help?
I'm using visual studio 2010 c++.
Use GetCurrentDirectory() function to retrieve current process directory. Then use search in the directory (FindFirstFile(), FindNextFile() and other) to detect and read all files in cycle.

Read all files in a folder then place each file and its match in new excel document. Is it possible with C++?

I have a folder that contains 300 different files. There are 150 .cft files and 150 .s01 files. Each .cft file has a corresponding .s01 file of the same name. I would like to create a program that can read the files from the folder and place each .cft file and its corresponding .s01 file into an excel document. I would like the .cft file to be on the first worksheet in the document and the .s01 file to be on the second sheet. Then I would like the program to save the file and name it (---------).xls. The (---------) would be the name of the .cft and .s01 file since they are both the same.
So!!! I wrote a program that is able to take the .cft file and the .s01 file, append them and place them in a user defined .xls document. However...I don't want to manually get the names of the 150 files and have to type each one into the program. I also don't want the files to be placed on the same worksheet.
So!!!! I don't want to waste time trying to code something impossible, so before I spend anymore time on this I have a few questions:
Is it possible to read all of the files in a folder and match files of the same name but with different types?
If this is possible, is it then possible to place the corresponding .cft file and .s01 file in the same excel document but on different worksheets?
Then, is it possible to create and save this worksheet as (---------).xls, (-------) being the name of the matching .cft and .s01 file?
So basically...I want to write this code because I am lazy and I don't want to do anything manually ><;;; lol
Example:
The main folder contains 8 files:
dog.cft dog.s01 cat.cft cat.s01 tree.cft tree.s01 bird.cft bird.s01
The program reads all of the files in the folder and recognizes that dog.cft and dog.s01 go together.
The program then creates an excel document and on worksheet 1 places dog.cft and on worksheet 2 places dog.s01.
The program then saves the excel document as dog.xls
Then the program loops through the main folder repeating this process for each of the .cft and .s01 pairs until all 150 pairs have been separated and saved in their own excel document.
I don't know if I'm dreaming a little too big with this but any advice is much appreciated!
personally I would do this with a macro in excel rather than in c++ because doing excel related functions is much easier that way. All of the requirements are possible using VBA within excel.
Yes, it's possible.
For the listing of files in a folder, you can use the Windows API functions FindFirstFile and FindNextFile. When you finish iterating the folder, you'll need to call FindClose.
For creating the Excel spreadsheet and working with the workbook's sheets, you can use COM automation. Here's a link to an article on doing so from C++ (MFC); the article explains where to find one that isn't MFC based.
If you get started and have specific questions about either of the tasks, please post them as separate questions. This should have been two individual questions, in fact - one about iterating the content of a folder and a different one about working with Excel files from C++.