Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to automate manual file conversion 5

Status
Not open for further replies.

Gaffi1

Technical User
Apr 23, 2004
70
0
0
US
Hi, we are currently recording sound files in rhet32 format and need them in wav8. We have a utility that converts the files for us, but it requires we type a command into a cmd prompt for every single audio file and this is becoming a pain staking process.

The command that we pass through the cmd prompt is:
Conv32 /it:rhet32 /ot:wav8 s0123456.123 s0123456.wav

The idea I was hoping of coming up with is a script that pulls a list of all files in a directory and if it's not a .wav file execute that command on it and move the original file to archives; then move on to the next file until non remain.

I've looked around for ideas of varying degree and none have worked so far. The two problems I have are a) getting the list of files and b) getting the conv32 command to work using variables. Example below:
set strFile = s075134j.066
set strNewFile = jamestest.wav
conv32 /it:rhet32 /ot:wav8 strfile strnewfile

This problem however passes the literal text "strfile strnewfile" to the command instead of their values.

Any suggestions on how I can bypass these two problems?
 
well... that's a wrap!!! I accomplished my mission and everything works extremely well. I can't think of anything else that I'll need now. Thank you to everyone who helped. I gave stars to each of you! I couldn't have done it without you!

Here is my final script:
Code:
Set WshShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strFolder= "C:\soundtest\"
WshShell.CurrentDirectory="c:\ConvUtil"
Set objFolder = objFSO.GetFolder(strFolder)

ScanSubFolders(objFolder)

Sub ScanSubFolders(objFolder)
Set colFolders = objFolder.SubFolders

For Each objSubFolders In colFolders

	Set subobjFile = objSubFolders.Files
	For Each objFiles in subobjFile
		strFile = objFiles.Name
		StrPath = objFiles.Path
		strNewFile = Left(strPath,InStrRev(strPath,".")) & "wav"
		strExtension = Right(strFile,Len(strFile)-InStrRev(strFile,"."))
		newpath = "C:\soundtest\qa\" & Right(objSubFolders,len(objSubFolders)-13) & "\"
		newfullpath = newpath & Left(strFile,InStrRev(strFile,".")) & "wav"
        	If strExtension <> "wav" Then
			If NOT objFSO.FileExists(newfullpath) Then
				WshShell.Run "conv32 /it:rhet32 /ot:wav8 " & "" & strPath & "" & " " & "" & strNewFile & "",0,false
                    		wshshell.run ("xcopy " & "" & strNewFile & "" & " " & "" & newpath & "" & " /Y")
			End If
		End If
	Next
Next
End sub

Call KillProc("conv32.exe")

Sub KillProc(strNameOfAppToKill)

Dim objWMI
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_Process")

   for each Process in objWMI
     If lcase(Process.Name) = lcase(strNameOfAppToKill) Then
         Process.Terminate
     End If
     
   next

End Sub

Call KillProc("xcopy.exe")

Sub KillProc(strNameOfAppToKill)

Dim objWMI
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_Process")

   for each Process in objWMI
     If lcase(Process.Name) = lcase(strNameOfAppToKill) Then
         Process.Terminate
     End If
     
   next

End Sub
 
HEHEHE, I'm back :)

OK, found a bug and I'm not sure what the heck is causing it...

The bug is in the xcopy process. While its copying everything the audio files to where they are supposed to go, when I go there to listen they won't play, indicating the codec is wrong. Yet all we are doing is copying the file from one spot to another. I echo'd the information being passed to xcopy and it appears to be correct so just to be sure I copied the information from the echo, passed it in manually to a cmd xcopy, and i was able to play that file. So, if its passing the right information, why would it not copy correctly?
 
ok, i don't know why the prior script wasn't working correctly, but thanks to someone else for tipping me off on a tweak to get it to work correctly. I modified the copy script to :
Code:
wshshell.Run ("cmd.exe /C xcopy " & "" & strNewFile & "" & " " & "" & newpath & "" & " /Y")

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top