Reputation: 1
Hi all i'm coding an application to rename music files (.mp3) located locally on my server; as it stands i have been very succesful on doing this when all the music files are stored on the PC. However my problem occurrs when using the same code to rename the files stored on the server it does something different.
My music files are stored as:
01 Track1.mp3
02 Track2.mp3
03 Track3.mp3
04 Track4.mp3
05 Track5.mp3
What I Want to have is a fullstop after the number:
01. Track1.mp3
02. Track2.mp3
03. Track3.mp3
04. Track4.mp3
05. Track5.mp3
All the files also have the track number stored in the hashtag column inside file explorer which are correct,
as said this code works perfect when the files are stored on the pc.
What I get when renaming the files stored on the server is:
02. Track1.mp3
04. Track2.mp3
05. Track3.mp3
01. Track4.mp3
03. Track5.mp3
It seems to rearrange the files to a random sort order then adds the sequential numbering which puts them out of order see pic below. I have also tried renaming the files so that all the files have the same name but with a number at the end to put them into an alphabetical order, but yet still does a random re-order.
I'm using visual basic to code this application.
the code that I am using is:
Dim Process As New ProcessStartInfo() With {.UseShellExecute = True,
.FileName = "powershell",
.WorkingDirectory = Pathtb.Text,
.WindowStyle = ProcessWindowStyle.Hidden,
.Arguments = "$i = [ref]1; gci *" & My.Settings.CustomEXT & " | rename-item -NewName {'{0:D" & My.Settings.CustomNumb & "}. {1}' -f $i.value++, $_.Name} "}
Using p As New Process()
p.StartInfo = Process
p.Start()
p.WaitForExit()
End Using
I have pasted this code directly into powershell itself and it still gives the same random outcome which leads to me to believe its a file explorer issue somewhere and not the code itself. I haven't done coding for a very long time so nothing is jumping out at me as to why it's doing this.
If anyone can share any thoughts that would be great thank you.
I hope this is clear to understand.
Upvotes: 0
Views: 39