Jump to content

Help with unpack.bat and .sh batch files


Meira

Recommended Posts

I have a problem with the batch file failing to work properly for some users. For most users (including myself) the following batch does exactly what it's supposed to do and all sound and graphic files are unpacked.

 

Windows:

@echo off
md Music\mxm#am
copy Amber\Music\*.ogg Music\mxm#am
copy Amber\Music\snd2acm.exe Music\mxm#am
copy Amber\sounds\oggdec.exe Music\mxm#am
cd Music\mxm#am
oggdec mxm#*.ogg
del mxm#*.ogg
del oggdec.exe
snd2acm.exe -wav mxm#amA.wav mxm#amA.acm
snd2acm.exe -wav mxm#amB1.wav mxm#amB1.acm
snd2acm.exe -wav mxm#amB2.wav mxm#amB2.acm
snd2acm.exe -wav mxm#amC.wav mxm#amC.acm
snd2acm.exe -wav mxm#amD.wav mxm#amD.acm
snd2acm.exe -wav mxm#amE1.wav mxm#amE1.acm
snd2acm.exe -wav mxm#amZ.wav mxm#amZ.acm
snd2acm.exe -wav mxm#amZC.wav mxm#amZC.acm
snd2acm.exe -wav mxm#amZD.wav mxm#amZD.acm
snd2acm.exe -wav mxm#amZE.wav mxm#amZE.acm
del mxm#*.wav
del snd2acm.exe
cd..
cd..
cd override
oggdec m#*.ogg
del m#*.ogg
del oggdec.exe
tisunpack m#ar*.tiz
del m#ar*.tiz
del tisunpack.exe
pause

 

Mac:

#!/bin/bash
mkdir -p music/mxm#am
cp amber/music/*.ogg music/mxm#am
cp amber/music/snd2acm music/mxm#am
cp amber/sounds/sox music/mxm#am
cd music/mxm#am
for file in mxm#*.ogg; do sox $file ${file%.ogg}.wav; done
rm -f mxm#*.ogg
rm -f sox
./snd2acm -wav mxm#amA.wav mxm#amA.acm 
./snd2acm -wav mxm#amB1.wav mxm#amB1.acm 
./snd2acm -wav mxm#amB2.wav mxm#amB2.acm 
./snd2acm -wav mxm#amC.wav mxm#amC.acm 
./snd2acm -wav mxm#amD.wav mxm#amD.acm 
./snd2acm -wav mxm#amE1.wav mxm#amE1.acm 
./snd2acm -wav mxm#amZ.wav mxm#amZ.acm 
./snd2acm -wav mxm#amZC.wav mxm#amZC.acm 
./snd2acm -wav mxm#amZD.wav mxm#amZD.acm 
./snd2acm -wav mxm#amZE.wav mxm#amZE.acm
rm -f mxm#*.wav
rm -f snd2acm
cd ..
cd ..
cd override
for file in m#*.ogg; do sox $file ${file%.ogg}.wav; done
rm -f m#*.ogg
rm -f sox
tisunpack -s m#ar*.tiz 
rm -f m#ar*.tiz
rm -f tisunpack

 

Yet to some users it fails over and over again on the line 7, where the oggdec or sox is supposed to be used in the music/mxm#am folder to unpack the music's .ogg files.

 

The error displayed for a mac user is this:

Amber/AmberUnpack.sh: line 7: sox: command not found

 

So my question is if I am doing something non-reliable in lines 2-6 that might lead to failure at line 7 for some users? Or if there's another explanation to this behaviour?

 

This error has now been reported for Win2000, WinXP and 'a G4 mac with OS 10.3', so I think I can say it's not connected to the operating system. At the moment I don't know if the folder mxm#am has been successfully created for the users that have this problem, but I'm trying to find out from the latest victim.

Link to comment

For the Mac (as well as Linux and other OSes), you need to use ./sox if you want to use the sox executable in the current directory - plain 'sox' would search it in the system directories (/bin, /usr/bin, etc.) rather than in the current one, so it could not find it if not installed.

 

As for Windows, I'll pass the question ;)

 

EDIT: also, I don't know if this causes problems in OSX, but the '#' character means 'comment' under bash. You need to escape it (mxm\#am) or enclose it in single quotes ('mxm#am')

Link to comment

There's more erors (Mac again):

 

Amber/AmberUnpack.sh: line 25: sox: command not found
Amber/AmberUnpack.sh: line 28: tisunpack: command not found

 

Yet according the .debug file, sox and tisunpack have been copied to the override:

 

Copied [amber/sounds/sox] to [override/sox]

 

Copied [amber/areas/tisunpack] to [override/tisunpack]

 

;)

Link to comment
For the Mac (as well as Linux and other OSes), you need to use ./sox if you want to use the sox executable in the current directory - plain 'sox' would search it in the system directories (/bin, /usr/bin, etc.) rather than in the current one, so it could not find it if not installed.

 

I believe the bigg has identified the root of the problem. My bad, this one eluded me completely. Since I do have sox and tisunpack installed on the system level, the issue didn't surface in my testing.

 

EDIT: also, I don't know if this causes problems in OSX, but the '#' character means 'comment' under bash. You need to escape it (mxm\#am) or enclose it in single quotes ('mxm#am')

 

It hasn't caused problems for me (ie conversion proceeds properly), but they should probably be changed just-in-case.

 

There's more erors (Mac again):

 

Amber/AmberUnpack.sh: line 25: sox: command not found
Amber/AmberUnpack.sh: line 28: tisunpack: command not found

 

Yet according the .debug file, sox and tisunpack have been copied to the override:

 

Copied [amber/sounds/sox] to [override/sox]

 

Copied [amber/areas/tisunpack] to [override/tisunpack]

 

Yeah, these errors would also be caused by calls to sox and tisunpack missing a ./ "prefix".

Link to comment

Like this? I didn't entirely understand if I need to enclose both folder and file names with # in quotes or just folder names. Also, I need to use ./sox only when I'm using the program, not when I'm copying or deleting it. Right?

 

 #!/bin/bash
mkdir -p music/'mxm#am'
cp amber/music/*.ogg music/'mxm#am'
cp amber/music/snd2acm music/'mxm#am'
cp amber/sounds/sox music/'mxm#am'
cd music/mxm#am
for file in 'mxm#*.ogg'; do ./sox $file ${file%.ogg}.wav; done
rm -f 'mxm#*.ogg'
rm -f sox
./snd2acm -wav mxm#amA.wav 'mxm#amA.acm' 
./snd2acm -wav mxm#amB1.wav 'mxm#amB1.acm' 
./snd2acm -wav mxm#amB2.wav 'mxm#amB2.acm' 
./snd2acm -wav mxm#amC.wav 'mxm#amC.acm'
./snd2acm -wav mxm#amD.wav 'mxm#amD.acm'
./snd2acm -wav mxm#amE1.wav 'mxm#amE1.acm' 
./snd2acm -wav mxm#amZ.wav 'mxm#amZ.acm' 
./snd2acm -wav mxm#amZC.wav 'mxm#amZC.acm' 
./snd2acm -wav mxm#amZD.wav 'mxm#amZD.acm' 
./snd2acm -wav mxm#amZE.wav 'mxm#amZE.acm'
rm -f 'mxm#*.wav'
rm -f snd2acm
cd ..
cd ..
cd override
for file in 'm#*.ogg'; do ./sox $file ${file%.ogg}.wav; done
rm -f 'm#*.ogg'
rm -f sox
./tisunpack -s 'm#ar*.tiz' 
rm -f 'm#ar*.tiz'
rm -f tisunpack

Link to comment

The whole expression where the offending character is used (e.g., mkdir -p 'music/mxm#am').

 

For your script, anything separated by whitespace that contains "#" (so you'd want ./snd2acm -wav 'mxm#amA.wav' 'mxm#amA.acm').

 

You only need to use "./" when executing something (it's really just a relative path marker for "here," so rm -f ./tisunpack would remove any file named "tisunpack" in the current working directory, but you shouldn't need it).

 

Other than the single quotes, the script looks fine now.

Link to comment
For your script, anything separated by whitespace that contains "#" (so you'd want ./snd2acm -wav 'mxm#amA.wav' 'mxm#amA.acm').

 

Okay, I realise that you said 'separated by whitespace', but what about a semicolon?

 

for file in 'mxm#*.ogg;' do ./sox $file ${file%.ogg}.wav; done

 

or

 

for file in 'mxm#*.ogg'; do ./sox $file ${file%.ogg}.wav; done

Link to comment

OK, my local copy of unpack.sh now looks like this:

 

#!/bin/bash
mkdir -p 'music/mxm#am'
cp amber/music/*.ogg 'music/mxm#am'
cp amber/music/snd2acm 'music/mxm#am'
cp amber/sounds/sox 'music/mxm#am'
cd 'music/mxm#am'
for file in 'mxm#'*.ogg; do ./sox $file ${file%.ogg}.wav; done
rm -f 'mxm#'*.ogg
rm -f sox
./snd2acm -wav 'mxm#amA.wav' 'mxm#amA.acm' 
./snd2acm -wav 'mxm#amB1.wav' 'mxm#amB1.acm' 
./snd2acm -wav 'mxm#amB2.wav' 'mxm#amB2.acm' 
./snd2acm -wav 'mxm#amC.wav' 'mxm#amC.acm' 
./snd2acm -wav 'mxm#amD.wav' 'mxm#amD.acm' 
./snd2acm -wav 'mxm#amE1.wav' 'mxm#amE1.acm' 
./snd2acm -wav 'mxm#amZ.wav' 'mxm#amZ.acm' 
./snd2acm -wav 'mxm#amZC.wav' 'mxm#amZC.acm' 
./snd2acm -wav 'mxm#amZD.wav' 'mxm#amZD.acm' 
./snd2acm -wav 'mxm#amZE.wav' 'mxm#amZE.acm' 
rm -f 'mxm#'*.wav
rm -f snd2acm
cd ..
cd ..
cd override
for file in 'm#'*.ogg; do ./sox $file ${file%.ogg}.wav; done
rm -f 'm#'*.ogg
rm -f sox
./tisunpack -s 'm#ar'*.tiz 
rm -f 'm#ar'*.tiz
rm -f tisunpack

 

Have I missed anything?

 

I did some quick playtesting (picked up Amber, got her bracelet back, advanced real time to get the first talks to trigger etc) and confirmed that all the files were (still) being converted and installed properly with this modified script.

Link to comment

For me the quotes seemed less scary. (Yes, I'm lame...)

 

Great, now I got better unpack.sh... ;)

 

The uninstal.sh should look like this, right?

 

cd music
rm -f 'm#blank.mus'
rm -f 'mxm#'*.mus
rm -f 'mxm#am/mxm#'*.acm
cd ..
rm -f 'override/m#boy'*.wav
rm -f 'override/m#gir'*.wav
rm -f 'override/m#dem'*.wav
rm -f 'override/m#rat'*.wav
rm -f 'override/m#ymm'*.wav
rm -f 'override/m#gab'*.wav
rm -f 'override/m#lor'*.wav
rm -f 'override/m#amb'*.wav
rm -f 'override/m#gbo'*.wav
rm -f 'override/m#ar'*.tis
echo
echo Amber Audio and Tilesets Uninstalled
echo

Link to comment
I'd switch to escaping the # in expressions with the wildcard (e.g., ./tisunpack -s m\#ar*.tiz), but only because the single quotes look stupid.
Thanks, duly noted. ;)
Why is 'junk'stuff less scary than \junkstuff?
For my part, the memory of "\" messing up pathing has given me something of an (admittedly irrational) aversion to it. :D
The uninstal.sh should look like this, right?

 

cd music
rm -f 'm#blank.mus'
rm -f 'mxm#'*.mus
rm -f 'mxm#am/mxm#'*.acm
cd ..
rm -f 'override/m#boy'*.wav
rm -f 'override/m#gir'*.wav
rm -f 'override/m#dem'*.wav
rm -f 'override/m#rat'*.wav
rm -f 'override/m#ymm'*.wav
rm -f 'override/m#gab'*.wav
rm -f 'override/m#lor'*.wav
rm -f 'override/m#amb'*.wav
rm -f 'override/m#gbo'*.wav
rm -f 'override/m#ar'*.tis
echo
echo Amber Audio and Tilesets Uninstalled
echo

 

Haven't edited my local copy of it yet, but this looks good to me too.

Link to comment
Why is 'junk'stuff less scary than \junkstuff?

 

Because I would have to put \ in middle of my filename (as opposite of around it, like quotes). Ultimately using \ would probably have been simpler because then I would not have needed to figure out how semicolons and asterisks and file paths affected the quotes, but initially they did seem less 'scary'. ;)

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...