I see. I would personally just have one folder that has the video files, but I get why you might not want to do that.
I'm caught up in something right now, but I could write up a program to collect a list of .avi and .mp4 files by recursively navigating the C: drive, and then choose one of them. Maybe I'll come back later, but no guarentees. Until then, if your batch file is working by calling it like
system("my.bat");
why not just do it like that? You're using system either way.
You could have your program write the file first, and then call the file it just made, that way it isn't dependent on a file existing.
C++17 has a filesystem library built-in, but I have not been able to use it because of shoddy support for MinGW. Boost also has a filesystem library. These are alternatives to using the Win32 API.
Boost filesystem example:
https://stackoverflow.com/questions/9366040/search-files-in-directory-and-subdirectory-using-boost-library-c
there doesn't seem to be anyway to tell c++ to find a random file and open it which is incredibly baffling to me... |
While it may seem simple, a lot actually goes into this. Such a specific operation as the one you request isn't going to be built-in to C++'s library, because it requires too many "building blocks" to work together at once in a specific way.
We need:
- (1) Random number generation + initialization
- (2) OS File system tree accessibility
- (3) Search through file system, recursively, for specific search patterns.
- (4) A way to collect the results found in (3) so that we can choose a random element from the collection
The recursive file system search will probably take more than 4 lines alone to work properly.