Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Threading, System.IO, System.Text
- Module Module1
- Public path As String
- Public i As Integer = 0
- 'Public rnd As New Random
- Sub Main()
- Console.Title = "Black Widow - Bulk File Renamer - V1.0"
- Console.ForegroundColor = ConsoleColor.Red
- Console.WriteLine("
- / \
- \ \ ,, / /
- '-.`\()/`.-'
- .--_'( )'_--.
- / /` /`**`\ `\ \
- | | >< | |
- \ \ / /
- '.__.'
- Randomize filenames en-masse!
- ")
- Console.ForegroundColor = ConsoleColor.Gray
- Console.Write(" Enter in path to directory: ")
- path = Console.ReadLine()
- Dim len As Integer = path.Length()
- Dim chkSlash As String = path
- chkSlash = chkSlash.Substring(len - 1)
- If chkSlash.ToString = "/" Then
- path = path.Remove(path.Length - 1)
- End If
- Console.WriteLine("
- Pending...
- ")
- 'Thread.Sleep(2000)
- For Each targFile In Directory.GetFiles(path)
- Dim fileName As String = genJunk(5, 15)
- 'Thread.Sleep(500)
- Dim targInfo As New IO.FileInfo(targFile)
- Dim fileExt As String = targInfo.Extension
- Do
- If My.Computer.FileSystem.FileExists(path + "\" + fileName + fileExt) Then
- fileName = fileName + i.ToString
- Else
- Exit Do
- End If
- Loop
- Try
- My.Computer.FileSystem.RenameFile(targFile, fileName + fileExt)
- Console.WriteLine(targFile + " ---> " + fileName + fileExt)
- Catch ex As Exception
- Console.WriteLine(" Critical error encountered!")
- End Try
- Next
- Console.WriteLine("
- Task completed! Strike ENTER to finalize.
- ")
- Console.ReadLine()
- Environment.Exit(0)
- End Sub
- Public Function genJunk(MinLength As Integer, MaxLength As Integer) As String
- Static rnd As New Random()
- Dim validchars() As Char = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLOMNOPQRSTUVWXYZ0123456789".ToCharArray()
- Dim res As String = ""
- For i As Integer = 0 To rnd.Next(MinLength - 1, MaxLength)
- res += validchars(rnd.Next(0, validchars.Length))
- Next
- Return res
- End Function
- End Module
Advertisement
Add Comment
Please, Sign In to add comment