shell-script-pt
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Como tratar arquivo com espaços no nome, dentro de um script


From: Mauricio Vieira
Subject: Como tratar arquivo com espaços no nome, dentro de um script
Date: Wed, 4 Apr 2007 08:13:49 -0300

Olá a todos,

 Fiz um pequeno script para converter arquivos ogg pra mp3 (a partir desta
msg, é domínio público).

#!/bin/sh

[ -z $1 ] && exit 1

ARQUIVOOGG=$1
EXTENSION=${ARQUIVOOGG:${#ARQUIVOOGG}-4:4}
#echo $EXTENSION
[ $EXTENSION == '.ogg' ] || exit 1

ARQUIVOMP3=${ARQUIVOOGG%.ogg}".mp3"
ARQUIVOMP3=${ARQUIVOOGG/ogg/mp3}

COMANDO="oggdec \"${ARQUIVOOGG}\" -o - | lame - \"${ARQUIVOMP3}\""
echo $COMANDO
$COMANDO

Acontece que os arquivos mp3 contém espaços no nome.
Um exemplo:

sh -x ~/bin/ogg2mp3.sh 07\ -\ Once\ Upon\ The\ Sea\ Of\ Blissful\
Awareness.ogg
+ '[' -z 07 - Once Upon The Sea Of Blissful Awareness.ogg ']'
/home/vieira/bin/ogg2mp3.sh: line 3: [: too many arguments
+ ARQUIVOOGG='07 - Once Upon The Sea Of Blissful Awareness.ogg'
+ EXTENSION=.ogg
+ '[' .ogg == .ogg ']'
+ ARQUIVOMP3='07 - Once Upon The Sea Of Blissful Awareness.mp3'
+ ARQUIVOMP3='07 - Once Upon The Sea Of Blissful Awareness.mp3'
+ COMANDO='oggdec "07 - Once Upon The Sea Of Blissful Awareness.ogg" -o - |
lame - "07 - Once Upon The Sea Of Blissful Awareness.mp3"'
+ echo oggdec '"07' - Once Upon The Sea Of Blissful 'Awareness.ogg"' -o -
'|' lame - '"07' - Once Upon The Sea Of Blissful 'Awareness.mp3"'
oggdec "07 - Once Upon The Sea Of Blissful Awareness.ogg" -o - | lame - "07
- Once Upon The Sea Of Blissful Awareness.mp3"
+ oggdec '"07' - Once Upon The Sea Of Blissful 'Awareness.ogg"' -o - '|'
lame - '"07' - Once Upon The Sea Of Blissful 'Awareness.mp3"'
OggDec 1.0.1
ERROR: Can only specify one input file if output filename is specified

Se eu pego a saida do meu 'echo' e colo no terminal, ele executa
corretamente. Exemplo:
oggdec "07 - Once Upon The Sea Of Blissful Awareness.ogg" -o - | lame - "07
- Once Upon The Sea Of Blissful Awareness.mp3"

Só que dentro do script, ele não tá encarando assim. Já tentei _escapar_ com
aspas, mas não tá funcionando. Alguém quem alguma sugestão?

agradeço antecipadamente (pra não encher a lista com msgs de agradecimento)

-- 
Mauricio B. C. Vieira
http://mauriciovieira.net


[As partes desta mensagem que não continham texto foram removidas]



reply via email to

[Prev in Thread] Current Thread [Next in Thread]