I often work on a lot of pictures, so I often want to export the name of the large batch of images to the TXT file to save for subsequent batch processing pictures.
My method is, if you have a large number of images stored in d:/img/, then you use the mouse to select the IMG folder, hold down the SHIFT key, right click here to open the Command window.
Type tree/f >d:\list.txt
This will generate a list.txt file in the D drive, but to manually delete some of the first and last words and empty lines, so that the left of every line of the picture name before the blank line, below I posted out I found on the Internet to remove these spaces of the code.
//
This program is used to remove and save extra space in the file to another file #include <iostream> #include <fstream> void Alltrim (char *); using namespace Std; void Alltrim (char *str) {char *p=str,*q=str; BOOL Notspace=false; while (*q== ') q++; while (*q!= ') {if (*q!= ') {notspace=true; *p++=*q++; Not a space, copy} else if (notspace)//is a space, but is currently the first (because the condition of the previous notspace=true; is not a space) { Notspace=false; The first space is still to be copied *p++=*q++; } else//In the event of a second or more space, it is precisely because of the first space encountered and copied, notspace=false; The reason, will come here {q++; Do not copy}} *p= ' + '; }int Main () {Ifstream sourcefile; Ofstream targetfile; Char str[100]; int num_char=0, num_line=0; int i; Sourcefile.open ("List.txt<span style=" font-family:arial, Helvetica, Sans-serif; " > ", ios::in); </span> if (!sourcefile)//test successfully opened { cerr<< "Input File Open error!" <<endl; Exit (1); } targetfile.open ("Nospace.txt", ios::out); if (!targetfile)//test successfully opened {cerr<< "output File Open error!" <<endl; Exit (1); } while (!sourcefile.eof ())//an article consisting of multiple lines {sourcefile.getline (str,100, ' \ n '); Alltrim (str); Delete the extra space//Save the character i=0 after deleting the space; while (* (str+i)! = ') ') {targetfile.put (* (str+i)); ++i; } targetfile.put (' \ n '); } sourcefile.close (); Targetfile.close (); cout<< "Processing is complete, please review the file. "<<endl; return 0; }
A stupid but effective way to export the name of a large batch of pictures to a TXT file