#include #include #include using namespace std; #pragma comment(lib, "Shlwapi.lib") int main() { char pfad[ 255 ]; while( 1 ) { cout << "gebe den ordner an:"; getchar(); cin.getline( pfad, 255 ); if( !PathFileExists( pfad ) ) { cout << "Fehler: Der Ordner existiert nicht." << endl; continue; } if( !strlen( pfad ) ) { cout << "Bitte gebe den Quellordner an." << endl; continue; } break; } cout << "----Start----" << endl; int länge = (int)strlen( pfad ); for( int i = 0; i < länge; i++ ) { if( pfad[ i ] == '/' ) pfad[ i ] = '\\'; } char pfad2[ 255 ]; memcpy( pfad2, pfad, länge ); if( pfad2[ länge - 1 ] == '\\' ) { pfad2[ länge - 1 ] = '2'; pfad2[ länge ] = '\\'; pfad2[ länge + 1 ] = 0; pfad[ länge ] = '*'; länge++; pfad[ länge ] = 0; } else { pfad2[ länge ] = '2'; pfad2[ länge + 1 ] = '\\'; pfad2[ länge + 2 ] = 0; pfad[ länge ] = '\\'; länge++; pfad[ länge ] = '*'; länge++; pfad[ länge ] = 0; } if( PathFileExists( pfad2 ) ) { cout << "Fehler: Zielverzeichnes existiert bereits." << endl; return 0; } _mkdir( pfad2 ); if( !PathFileExists( pfad2 ) ) { cout << "Fehler: Zielverzeichnes konnte nicht erstellt werden." << endl; return 0; } WIN32_FIND_DATA wfd; HANDLE fHandle = FindFirstFile( pfad, &wfd ); FindNextFile( fHandle, &wfd ); länge = (int)strlen( pfad2 ); char c[ 3 ] = { 'a', 'a', 'a' }; while( FindNextFile( fHandle, &wfd ) ) { char datei[ 255 ]; memcpy( datei, pfad, strlen( pfad ) ); for( int i = 0; i < (int)strlen( wfd.cFileName ); i++ ) datei[ strlen( pfad ) + i - 1 ] = wfd.cFileName[ i ]; datei[ strlen( pfad ) + strlen( wfd.cFileName ) - 1 ] = 0; char datei2[ 255 ]; memcpy( datei2, pfad2, länge ); datei2[ länge ] = 'f'; datei2[ länge + 1 ] = c[ 0 ]; datei2[ länge + 2 ] = c[ 1 ]; datei2[ länge + 3 ] = c[ 2 ]; datei2[ länge + 4 ] = '.'; datei2[ länge + 5 ] = 'p'; datei2[ länge + 6 ] = 'n'; datei2[ länge + 7 ] = 'g'; datei2[ länge + 8 ] = 0; MoveFile( datei, datei2 ); c[ 2 ]++; if( c[ 2 ] > 'z' ) { c[ 2 ] = 'a'; c[ 1 ]++; if( c[ 1 ] > 'z' ) { c[ 1 ] = 'a'; c[ 0 ]++; if( c[ 0 ] > 'z' ) { cout << "Fehler: Es sind über 17576 Dateien in dem ordner." << endl; return 0; } } } } FindClose( fHandle ); cout << "----Ende----" << endl; return 1; }