Reputation: 506
So I made the mistake of letting iTunes manage my music, and now any song that has more than one artist is in a separate sub-directory. I am trying to get all music files from all of the nested directories that iTunes created, and dump them into one folder so that I can use a more competent program to organize my music (no offense to iTunes fans).
I am aware of how to copy the directories to another location, as well as listing out the directories and sub directories as illustrated here
My assumption is that I would have to list all directories, sub-directories, and contents of those directories, and then loop through each file string.
Is there a way to get a list of all files (not directories) within a directory tree to simplify the process?
Upvotes: 1
Views: 2387
Reputation: 2327
Try System.Io.Directory.GetFiles
with the overload for SearchOptions
. That lets you specify searching all subdirectories.
Not sure if that is exactly what you are looking for, but should get you started.
http://msdn.microsoft.com/en-us/library/ms143448.aspx
using System;
using System.IO;
DirectoryInfo itunes = new DirectoryInfo("MyItunesPath");
FileInfo[] itunesFiles =
itunes.GetFiles("*.*", SearchOption.AllDirectories);
Upvotes: 2