I just copied all my cds to my computer with a program called "Sound Juicer". It works fine, it creates for each artist a folder and it it for each album another folder. And of course in these folders the mp3 files.
The problem is I want the Tracknumber, the Artist and then the Tracktitle as name for my songs. What Sound Juicer does is adding d1t in front of the file which stands for "Disk 1 Title".
I'm a programmer so I used this problem to practice a little bit. This works :
void MainWindow::rename( const QString & text )
{
static int _files = 0;
QDir dir( text );
QFileInfoList a = dir.entryInfoList( QDir::Files | QDir::Dirs );
for( int i = 2; i < a.size(); i++ )
{
static QDir tmp;
if( a.at( i ).isDir() )
rename( a.at( i ).absoluteFilePath() );
if( a.at( i ).fileName().startsWith( "d1t" ) || a.at( i ).fileName().startsWith( "d2t" ) )
{
QString newFile = a.at( i ).fileName().remove(0,3);
tmp = a.at( i ).dir();
if( !tmp.rename( a.at( i ).fileName(), newFile ) )
qDebug() << "Failed";
_files++;
}
}
}
It checks a directory, selects the first file or directory and checks what it is. If it is a directory it calls itself (recursion) and starts again until he finds some files or no more directories exist. If a file is found, it renames it and adds 1 to the file counter.
However, it only renamed all files in the first 2 or 3 directories. After that it caused a SIGSEGV. Does anyone knows whats wrong?
Example of my directories :
1 Directory ("Sum 41") -> 1 Subdirectory ("All Killer No Filler") -> Files "d1t01. Sum 41 - Introduction to Destruction.mp3" etc. ... 2 Subdirectory ("Blah Blah") -> Files ...
2 Directory ("Shinedown") -> 1 Subdirectory ("Sound of Madness") -> Files d1t01. Shinedown - Devour.mp3 etc...
3 Directory ("Guns N’ Roses") -> Subdirectory ("Blah Blah") -> files ... Subdirectory ("Blah ") -> files ...