jrjacobs
IS-IT--Management
- Dec 5, 2002
- 11
Code 800A003A
I have a script that randomly renames the first three charachters of files to allow a random play order. It worked before the latest updates but does not now.
Can anybody help?
--------------script below----------------
const FilesSubFolders="samples\Music"
Napis = "Run InFlight Music Randomizer for IL2 ?" & chr(10) & "(use parameter /s to suppress messages)"
Titulek = "Windows Scripting Host"
Dim intDoIt
Dim fso, fold, ffil, ffilact, num
Dim ShowMessages
'Parameter /s will run it silently
Messages=True
FileCounter=0
'Get commandline arguments.
set objArgs = WScript.Arguments
'WScript.Echo "Total number of arguments: " & WScript.Arguments.Count
for each strArg in objArgs
'WScript.Echo strArg
If Ucase(StrArg) = "/S" or Ucase(StrArg) = "/SILENT" then
Messages = False
End if
next
'Create a loop in which we will check all subfolders,
'masked "samples\Music\InFlight*"
Randomize
If Messages then Call Welcome()
'List of Subfolders
Dim sFso
Dim sFolder
Set sFso = CreateObject("Scripting.FileSystemObject")
'Collection of subfolders in the subdir Music
Set sFolder = sfso.GetFolder(FilesSubFolders)
'Loop all folders
For Each item in sFolder.Subfolders
'msgbox item.Name
'If the folder name starts with 'InFlight', then renames files in it
If ucase(left(item.name,Len("Inflight")))=Ucase("Inflight") then
'msgbox FilessubFolders & "\" & Item.Name
RenameFilesThisFolder( FilessubFolders & "\" & Item.Name)
End if
Next
If Messages then msgbox "Run IL2 and Enjoy"
Wscript.Quit
Msgbox "Should not see me!"
Sub RenameFilesThisFolder(FilesSubdir)
Set fso = CreateObject("Scripting.FileSystemObject")
Set fold = fso.GetFolder(Fso.getAbsolutePathName("")& "\" & Filessubdir)
'Collection of files in this Folder
Set ffil = fold.Files
'Loop all files
For Each ffilact in ffil
'Randomize a number
num=RandoChars()
ffilact.move(fold.path & "\" & string(3-len(cstr(num)),"0") & cstr(num) & right(ffilact.name,len(ffilact.name)-3))
Next
End sub
Sub Welcome()
intDoIt = MsgBox(Napis, vbOKCancel + vbinformation, Titulek )
If intDoIt = vbCancel Then WScript.Quit
End Sub
Function RandoChars()
RandoChars=int(rnd*999)
End Function
I have a script that randomly renames the first three charachters of files to allow a random play order. It worked before the latest updates but does not now.
Can anybody help?
--------------script below----------------
const FilesSubFolders="samples\Music"
Napis = "Run InFlight Music Randomizer for IL2 ?" & chr(10) & "(use parameter /s to suppress messages)"
Titulek = "Windows Scripting Host"
Dim intDoIt
Dim fso, fold, ffil, ffilact, num
Dim ShowMessages
'Parameter /s will run it silently
Messages=True
FileCounter=0
'Get commandline arguments.
set objArgs = WScript.Arguments
'WScript.Echo "Total number of arguments: " & WScript.Arguments.Count
for each strArg in objArgs
'WScript.Echo strArg
If Ucase(StrArg) = "/S" or Ucase(StrArg) = "/SILENT" then
Messages = False
End if
next
'Create a loop in which we will check all subfolders,
'masked "samples\Music\InFlight*"
Randomize
If Messages then Call Welcome()
'List of Subfolders
Dim sFso
Dim sFolder
Set sFso = CreateObject("Scripting.FileSystemObject")
'Collection of subfolders in the subdir Music
Set sFolder = sfso.GetFolder(FilesSubFolders)
'Loop all folders
For Each item in sFolder.Subfolders
'msgbox item.Name
'If the folder name starts with 'InFlight', then renames files in it
If ucase(left(item.name,Len("Inflight")))=Ucase("Inflight") then
'msgbox FilessubFolders & "\" & Item.Name
RenameFilesThisFolder( FilessubFolders & "\" & Item.Name)
End if
Next
If Messages then msgbox "Run IL2 and Enjoy"
Wscript.Quit
Msgbox "Should not see me!"
Sub RenameFilesThisFolder(FilesSubdir)
Set fso = CreateObject("Scripting.FileSystemObject")
Set fold = fso.GetFolder(Fso.getAbsolutePathName("")& "\" & Filessubdir)
'Collection of files in this Folder
Set ffil = fold.Files
'Loop all files
For Each ffilact in ffil
'Randomize a number
num=RandoChars()
ffilact.move(fold.path & "\" & string(3-len(cstr(num)),"0") & cstr(num) & right(ffilact.name,len(ffilact.name)-3))
Next
End sub
Sub Welcome()
intDoIt = MsgBox(Napis, vbOKCancel + vbinformation, Titulek )
If intDoIt = vbCancel Then WScript.Quit
End Sub
Function RandoChars()
RandoChars=int(rnd*999)
End Function