Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: C++ trying to figure out how to clip file extensions for project  (Read 9791 times)

0 Members and 1 Guest are viewing this topic.

Salmon Trout

  • Guest
Re: C++ trying to figure out how to clip file extensions for project
« Reply #15 on: August 10, 2011, 01:14:51 AM »
..

DaveLembke

    Topic Starter


    Sage
  • Thanked: 662
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: C++ trying to figure out how to clip file extensions for project
« Reply #16 on: August 14, 2011, 04:01:44 PM »
Thanks Salmon, and no apology needed... I dont feel that it was hijacked..lol   I welcome all input on the matter!

Thanks for showing me how to strip off the file extension with

Code: [Select]
for /f "delims=" %%A in ('dir /b *.mp4') do echo %%~nA >> list.txt
And clarifying %cd% vs my assumption of %cc%

Khasiar



    Intermediate

    Re: C++ trying to figure out how to clip file extensions for project
    « Reply #17 on: September 15, 2011, 11:19:10 PM »
    here's another idea, im going to skip the error checking


    ifstream inFile;
    string temp;
    vector<string> fileNames, newFileNames;



    system("dir /s /b *.mp4 *.avi *.mpeg >> out.txt");
    inFile.open("out.txt");

    while(inFile){

       getline(inFile, temp);
       fileNames.push_back(temp);

    }//while

    inFile.close();

    for (int i = 0; i < fileNames.size(); i++){

       for (int i2 = fileNames.at(i).size() - 1; i2 >= 0 ; i2--)
          if (fileNames.at(i).at(i2) == '.'){
             newFilesNames.push_back(fileNames.at(i).substr(0, (fileNames.at(i).size() - (fileNames.at(i).size() - i2 ))
             i2 = -1

          }//if


    }//for

    then youd probably want to rename the file

    string temp, cmd= "rename ";

    for (int i = 0; i < newFileNames.size(); i++){

    temp = cmd + fileNames.at(i) + " " + newFileNames.at(i);
    system(temp.c_str());

    }//for

    something along these lines, didnt really get to test it but ive done a similar project before