Advertisement
SpoOkyMagician

Program 1

Sep 20th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 9.23 KB | None | 0 0
  1. Imports System
  2. Imports System.IO
  3. Imports System.Collections
  4.  
  5. Public Class frm_main
  6.     Dim dir_a As String = "C:\Users\Jeremy\AppData\Roaming\StepMania 5\Songs"
  7.  
  8.     Dim files() As String
  9.  
  10.     Dim directories() As String
  11.     Dim sub_directories() As String
  12.     Dim sub_sub_directories() As String
  13.  
  14.     Dim simfile_counter As Long = 0
  15.     Dim audio_counter As Long = 0
  16.     Dim image_counter As Long = 0
  17.     Dim video_counter As Long = 0
  18.     Dim lyric_counter As Long = 0
  19.  
  20.     Dim song_filename As String = ""
  21.     Dim song_extention As String = ""
  22.  
  23.  
  24.     Public Sub frm_main_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  25.  
  26.         ' these are the current directory and files. meaning...
  27.         ' "C:\Users\Jeremy\AppData\Roaming\StepMania 5\Songs\FILES"
  28.         ' "C:\Users\Jeremy\AppData\Roaming\StepMania 5\Songs\DIRECTORIES"
  29.         directories = Directory.GetDirectories(dir_a)
  30.  
  31.         ' for all the directories in d...
  32.         For Each d In directories
  33.  
  34.             ' get the sub directories here for later... meaning...
  35.             ' "C:\Users\Jeremy\AppData\Roaming\StepMania 5\Songs\DIRECTORIES\SUB DIRECTORIES"
  36.             sub_directories = Directory.GetDirectories(d)
  37.  
  38.             ' display the current directory we are in. meaning...
  39.             ' "C:\Users\Jeremy\AppData\Roaming\StepMania 5\Songs\DIRECTORY"
  40.             '  MessageBox.Show("Directory Name is : " + d)
  41.  
  42.             ' for all sub directories in sd...
  43.             For Each sd In sub_directories
  44.  
  45.                 ' get the sub sub directories here for later... meaning...
  46.                 ' "C:\Users\Jeremy\AppData\Roaming\StepMania 5\Songs\DIRECTORIES\SUB DIRECTORIES\SUB DIRECTORIES"
  47.                 sub_sub_directories = Directory.GetDirectories(sd)
  48.  
  49.                 ' display the current sub directory we are in. meaning...
  50.                 ' "C:\Users\Jeremy\AppData\Roaming\StepMania 5\Songs\DIRECTORY\SUB DIRECTORY"
  51.                 '  MessageBox.Show("Sub Sub Directory Name is  : " + sd)
  52.  
  53.                 files = Directory.GetFiles(sd)
  54.  
  55.                 ' For all files in f...
  56.                 For Each f In files
  57.  
  58.                     ' get the files here for later... meaning...
  59.                     ' "C:\Users\Jeremy\AppData\Roaming\StepMania 5\Songs\DIRECTORY\FILES"
  60.                     '   sub_files = Directory.GetFiles(f)
  61.  
  62.                     ' display the current file. meaning...
  63.                     ' "C:\Users\Jeremy\AppData\Roaming\StepMania 5\Songs\DIRECTORY\FILE"
  64.                     ' MessageBox.Show("Filename is : " + f)
  65.  
  66.                     ' see if we found a simfile...
  67.                     If Path.GetExtension(f) = ".sm" Then
  68.                         Try
  69.                             simfile_counter = simfile_counter + 1
  70.                             My.Computer.FileSystem.RenameFile(f, "chart_" + Convert.ToString(simfile_counter) + ".sm")
  71.                         Catch ex As Exception
  72.                             ' lol nope.
  73.                         End Try
  74.                     ElseIf Path.GetExtension(f) = ".ssc" Then
  75.                         Try
  76.                             simfile_counter = simfile_counter + 1
  77.                             My.Computer.FileSystem.RenameFile(f, "chart_" + Convert.ToString(simfile_counter) + ".ssc")
  78.                         Catch ex As Exception
  79.                             ' lol nope.
  80.                         End Try
  81.                     ElseIf Path.GetExtension(f) = ".dwi" Then
  82.                         Try
  83.                             simfile_counter = simfile_counter + 1
  84.                             My.Computer.FileSystem.RenameFile(f, "chart_" + Convert.ToString(simfile_counter) + ".dwi")
  85.                         Catch ex As Exception
  86.                             ' lol nope
  87.                         End Try
  88.                     ElseIf Path.GetExtension(f) = ".old" Then
  89.                         Try
  90.                             My.Computer.FileSystem.DeleteFile(f)
  91.                         Catch ex As Exception
  92.                             ' lol nope.
  93.                         End Try
  94.                     Else
  95.                         ' do nothing.
  96.                     End If
  97.  
  98.                     ' see if we found a audio file...
  99.  
  100.                     If Path.GetExtension(f) = ".mp3" Then
  101.                         Try
  102.                             audio_counter = audio_counter + 1
  103.                             My.Computer.FileSystem.RenameFile(f, "song_" + Convert.ToString(audio_counter) + ".mp3")
  104.                         Catch ex As Exception
  105.                             ' lol nope.
  106.                         End Try
  107.  
  108.                     ElseIf Path.GetExtension(f) = ".ogg" Then
  109.                         Try
  110.                             audio_counter = audio_counter + 1
  111.                             My.Computer.FileSystem.RenameFile(f, "song_" + Convert.ToString(audio_counter) + ".ogg")
  112.                         Catch ex As Exception
  113.                             ' lol nope.
  114.                         End Try
  115.                     Else
  116.                         ' do nothing.
  117.                     End If
  118.  
  119.                     ' see if we found a image file...
  120.                     If Path.GetExtension(f) = ".png" Then
  121.                         Try
  122.                             image_counter = image_counter + 1
  123.                             My.Computer.FileSystem.RenameFile(f, "bg_bn_cd_o_" + Convert.ToString(image_counter) + ".png")
  124.                         Catch ex As Exception
  125.                             ' lol nope.
  126.                         End Try
  127.                     ElseIf Path.GetExtension(f) = ".bmp" Then
  128.                         Try
  129.                             image_counter = image_counter + 1
  130.                             My.Computer.FileSystem.RenameFile(f, "bg_bn_cd_o_" + Convert.ToString(image_counter) + ".bmp")
  131.                         Catch ex As Exception
  132.                             ' lol nope.
  133.                         End Try
  134.                     ElseIf Path.GetExtension(f) = ".jpg" Or Path.GetExtension(f) = ".jpeg" Then
  135.                         Try
  136.                             image_counter = image_counter + 1
  137.                             My.Computer.FileSystem.RenameFile(f, "bg_bn_cd_o_" + Convert.ToString(image_counter) + ".jpg")
  138.                         Catch ex As Exception
  139.  
  140.                         End Try
  141.                     ElseIf Path.GetExtension(f) = ".gif" Then
  142.                         Try
  143.                             image_counter = image_counter + 1
  144.                             My.Computer.FileSystem.RenameFile(f, "bg_bn_cd_o_" + Convert.ToString(image_counter) + ".gif")
  145.                         Catch ex As Exception
  146.  
  147.                         End Try
  148.                     Else
  149.                         ' do nothing.
  150.                     End If
  151.  
  152.                     ' see if we found a video file...
  153.                     If Path.GetExtension(f) = ".avi" Then
  154.                         Try
  155.                             video_counter = video_counter + 1
  156.                             My.Computer.FileSystem.RenameFile(f, "video_" + Convert.ToString(video_counter) + ".avi")
  157.                         Catch ex As Exception
  158.                             ' lol nope.
  159.                         End Try
  160.                     ElseIf Path.GetExtension(f) = ".mp4" Then
  161.                         Try
  162.                             video_counter = video_counter + 1
  163.                             My.Computer.FileSystem.RenameFile(f, "video_" + Convert.ToString(video_counter) + ".mp4")
  164.                         Catch ex As Exception
  165.                             ' lol nope.
  166.                         End Try
  167.                     ElseIf Path.GetExtension(f) = ".mov" Then
  168.                         Try
  169.                             video_counter = video_counter + 1
  170.                             My.Computer.FileSystem.RenameFile(f, "video_" + Convert.ToString(video_counter) + ".mov")
  171.                         Catch ex As Exception
  172.                             ' lol nope.
  173.                         End Try
  174.                     ElseIf Path.GetExtension(f) = ".wmv" Then
  175.                         Try
  176.                             video_counter = video_counter + 1
  177.                             My.Computer.FileSystem.RenameFile(f, "video_" + Convert.ToString(video_counter) + ".wmv")
  178.                         Catch ex As Exception
  179.                             ' lol nope.
  180.                         End Try
  181.                     Else
  182.                         ' do nothing.
  183.                     End If
  184.  
  185.                     ' I forgot about lyric files...
  186.                     If Path.GetExtension(f) = ".lrc" Then
  187.                         Try
  188.                             lyric_counter = lyric_counter + 1
  189.                             My.Computer.FileSystem.RenameFile(f, "lyric_" + Convert.ToString(lyric_counter) + ".lrc")
  190.                         Catch ex As Exception
  191.                             ' lol nope.
  192.                         End Try
  193.                     End If
  194.  
  195.                 Next f
  196.  
  197.                 ' we should be able to reset the counter after we check all the files.
  198.                 simfile_counter = 0
  199.                 audio_counter = 0
  200.                 image_counter = 0
  201.                 video_counter = 0
  202.                 lyric_counter = 0
  203.  
  204.             Next sd
  205.  
  206.         Next d
  207.  
  208.         MessageBox.Show("DONE!")
  209.  
  210.     End Sub
  211.  
  212. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement