?
So habs geschafft, jetzt will ich es nur noch hinbekommen das ich mehrere Dateien markieren kann und gleichzeitig umbennen lassen, ich hab ganz google durchforstet und nich gefunden wie das geht :(, die anzahl der Argumente bleibt immer gleich, auch wenn ich mehrere DAteien markiere.
/* a_renamer.c */
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
using namespace std;
int main(int argc, char *argv[]) {
string oldname,newname;
string::size_type stpath,stdivide,stending;
string path,first,second,ending;
string::iterator i;
//int y;
//for(y=0;y<argc;y++) {
oldname = argv[1];
stpath = oldname.find_last_of("\\");
stdivide = oldname.find_last_of("-");
stending = oldname.find_last_of(".");
path = oldname.substr(0,stpath+1);
first = oldname.substr(stpath+1,stdivide-stpath-1);
second = oldname.substr(stdivide+1,stending-stdivide-1);
ending = oldname.substr(stending,string::npos);
for(i=first.end()-1;i!=first.begin();i--) {
if(*i==' ') {
first.erase(i);
}else{
break;
}
}
i=second.begin();
while(*i==' ') {
second.erase(i);
}
newname = path+second+" - "+first+ending;
rename(oldname.c_str(),newname.c_str());
//}
return EXIT_SUCCESS;
}