phil.o has already pointed you in the right direction.
You only need to get the filenames from the folder once.
There is no need to get
FileInfo
for each of the files, you can use methods on the
Path[
^] class instead - specifically the methods that give you just the base filename and just the extension.
The line
Dim sourcePath As String = DJdr
is also redundant - just use
DJdr
Although you can rename files during a move operation I would suggest just renaming the file in situ using the
FileSystem.Rename[
^] method. Of course, if you need to move the files into another folder then use the Move method.
You probably also want to put all of this into a sub-routine so that you can call it for the different DJs.
Finally, what happens if you run this twice? The previously renamed files will get the initials added on again - but you will probably need to run this regularly to handle any new files. So add a check to see if it's already been done.
For example:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
RenameFilesForAuthor("*.txt", "C:\Users\DaBeast\Desktop\PR", "PR")
RenameFilesForAuthor("*.txt", "C:\Users\DaBeast\Desktop\AF", "AF")
End Sub
Private Sub RenameFilesForAuthor(searchPattern As String, folderName As String, ownerInitials As String)
For Each fileName As String In Directory.GetFiles(folderName, searchPattern, SearchOption.AllDirectories)
If Not fileName.Contains(String.Format("({0}", ownerInitials)) Then
Dim newName As String = String.Format("({0}){1}{2}", _
ownerInitials, _
Path.GetFileNameWithoutExtension(fileName), _
Path.GetExtension(fileName))
My.Computer.FileSystem.RenameFile(fileName, newName)
End If
Next
End Sub