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

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

Re: [shell-script] Como tratar arquivo com espaço s no nome, dentro de u


From: Christian Andreas Miniero Casza
Subject: Re: [shell-script] Como tratar arquivo com espaço s no nome, dentro de um script
Date: Wed, 4 Apr 2007 8:34:07 -0300
User-agent: RoundCube Webmail/0.1b

Maurício,

utilize o sed para converter '\ ' em '\\\ ' no nome do arquivo.
Seria: sed 's/\ /\\\ /g'.

Isso deve resolver seu problema.

On Wed, 4 Apr 2007 08:13:49 -0300, "Mauricio Vieira" <address@hidden> wrote:
> 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]
> 
> 
> 
--
Christian Andreas Miniero Casza
Administrador de Sistemas
address@hidden
address@hidden
+55 11 8173-7882
+55 11 5643 7846



reply via email to

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