views:

36

answers:

2

I have a problem with my script. What i want it to do is take the first .m4a file of multiple .m4p files and do faad(it converts the .m4p file to a wave file but keeps the .m4p file),then BEFORE it goes on to the next .mp4 file i want it to do oddenc on the .wave that was newly created via the faad command, this creates an .ogg file.Id then like the script to del the m4a file and the wave file. And Only then move on to the next .m4a file in the dir to convert Also i need it to do it to multiple folders. What i have works ,but its messy.First goes through every .m4a file in every folder and creates the wave files, so now i have .m4a files and wave files in every dir, it then further creates an .ogg file in every folder. So i now have All the .m4ps .waves and .ogg`s in the same folders, before they get deleted. It uses lots of space and i think there must be a way of converting each file and deleting it as it goes along This is what i have so far

for /r %%i in (.m4a) do faad "%%i"
for /r %%i in (
.wav) do oggenc "%%i"
for /r %%i in (.m4a) do del "%%i"
for /r %%i in (
.wav) do del "%%i"

but i want something like

for /r %%i in (*.mpa) do faad "%%i" (*wav) do oggenc "%%i" (*m4a) do del "%%i" (*wav) do del "%%i"

Is there a way i could achieve this that works, because the above code doent :)

A: 

You'll be wanting braces for multiple commands, and %~n to get the filename (without extension) from the parameter:

::: Please define folder to search in (recursively)
if "%~1"=="" findstr "^:::" "%~f0"&GOTO:EOF

for /f %%i in ('dir %1\*.mp4 /b/s') do (
  faad "%%i"
  oggenc "%%~di%%~pi%%~ni.wav"
  del "%%~ni.m4a"
  del "%%~di%%~pi%%~ni.wav"
)

This relies on faad turning filename.mp4 -> filename.wav

Update: You need to supply 1 command line argument - the folder to recursively search, that is, all subfolders will be checkd for mp4 files and processed.

Rudu
Thanks Rudi ,i tried it but it didnt work. not sure why
kam
I should note that im using Windows7
kam
Try prefixing line 2+3 with echo (`echo faad "%%i"`) and commenting out line 4+5 (the deletes) and see what is printed on screen. Without `faad` and `oggenc` I can't test what is isn't working.
Rudu
Thanks for your quick reply Rudi. I did as suggested, but when i run the script it just exits. even if put a pause at the end of the script it ignores the pause and exits. It`s got me perplexed
kam
for /r %%i in (*.m4a) do faad "%%i"for /r %%i in (*.wav) do oggenc "%%i" works but as i said it`s a resource hog
kam
@Kam - Opps! I updated the code, I was missing the %% marks for lines 3,4,5. (Which was the error message I was getting) The resource-hoggy nature of this process isn't likely to be reduced that much by this arrangement over multiple for loops.
Rudu
Okay im starting to get somewhere, the code wasnt running because i needed to have two %% in the %~ni so it would be like %%~ni. Well it gets past the first bit and creates the Wave,but then "error".The next line Oggenc "%%~ni.wav" seems to work but it spits out an error Cannot open input file"Sound_005.wav" No such file or directory.And That is weird because when i check the folder it`s there.I added the pause`s just to check what was happening. Any idea`s Rudi :)for /r %%i in (*.mp4) do ( faad "%%i" pause oggenc "%%~ni.wav"pause )(pause
kam
Are you certain "Sound_005.wav" exists with exactly that name? Is it in the same folder or some subfolder? Does oggenc deal with long filenames? (your example filename is >8.3) If your filenames are also without spaces/special characters you can drop the quotes around `%%~ni.wav` (oggenc maynot be properly dealing with these).
Rudu
okay i can get it to work, but only if the .mp4 files are in the same dir as the batch script this is what i have so far for /r %%i in (*.mp4) do ( faad "%%i" pauseoggenc %%~ni.wavpause )but in sub folers it only converts the .mp4 to .wav,it displays in the CMD window that its also creating .ogg`s but it doesn`t.Just the Main diectory works.Ill try the /s command instead of /r maybe that will help lol 6.40am been working on this since 10pm yesterday
kam
actually it doesnt say its working in sub folders. I have a folder named FEET and in that folder there is 20 more folders with names such as BANK_001 and so on. in each of those folders will be manny .mp4 files with different names but repeating in the other folders eg Sound_005.mp4 may be the name of a file in all 20 folders, though the sound itself is different.Dont understand why oggenc will only work in the root dir while faad works in all subs
kam
{Updated (above)} Say you want to process `c:\FEET` and the batch file is called `looper.bat` call: `looper c:\FEET` (to process all mp4 files in and subfolders).
Rudu
When you said to define the folders to search, do you mean put dir F:\AudioCompressing\CONVERTING\FEET at the start of the code where Feet is the starting dir. this didnt work instant exit. also tried CD path of folder to convert, same deal exit. I should addmitt though that im just a Hack when it comes to codding.
kam
Well this is a strange one. The Code seems to work but gets stuck in an infinite loop. could be because i echoed the del functions though so ill check that out. Its weird that i have to call the script from another script for it to work, but hey if its not broken... I put F:\AudioCompressing\CONVERTING\FEET at the start of the Mp42Ogg.bat script then called the script in a CallMp42Ogg.bat script. When i execute the CallMp42Ogg.bat it does execute the script and it seems to work. but it goes on a loop that never stops..?
kam
kam
Doesnt delete the .mp4 or .wave and seems to loop recursively. It will go into the first folder Convert .mp4 to .wav to .ogg then not delete the .wav .mp4 then it goes to the next folder and does the same, it then goes back to the first folder and repeats itself and then the second folder. It then moves to the third folder and does the same going back to the first ect The pattern is there but i have no idea why its doing it. Could it be the script that calls the Mp42Ogg.bat Because all that has in it is Call Mp42Ogg.bat Your help has been greatly appreciated
kam
A: 

You might also consider using dir2ogg to simplify the process if you have Python installed. It might be a bit of a challenge to get the binaries it's dependent on installed in Windows, though.

Segphault
Looked into it but the script has to be run on Computers that might not have python
kam
I should note that im using Windows7
kam
Also i dont know how to code compile in python
kam