A stupid but effective way to export the name of a large batch of pictures to a TXT file

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.