Mailing List Archive

Find won't work always
Hi,

Find give's me errors in some directories, i have created a little script for renaming about 3000 mp3 files (removing spaces from the file manes)
I tested the find command in a directory with a dummy file and it works, now i'm going to test it on a real directory i get a error that my find syntax is wrong, but its always the same.
Can anyone put some light on this, renaming that dir won't help.

test dir (works)
pwd = /home/patrick/rename_testen
patrick@Inteprid rename_testen $ find . -name *.mp3 -exec ./ikke.sh '{}' \;

real dir (don't work)
pwd = /data/muziek/tunes
patrick@Inteprid tunes $ find . -name *.mp3 -exec ./ikke.sh '{}' \;
find: padnamen moeten de expressies voorgaan
Gebruik: find [pad...] [expressie]

works (but with false ikke.sh)
pwd = /data/muziek
patrick@Inteprid muziek $ find . -name *.mp3 -exec ./ikke.sh '{}' \;
find: ./ikke.sh: Onbekend bestand of map (because ikke.sh isn't there, just for a test)

the ikke.sh
#/bin/bash
#Purpose rename a file with spaces to underscores

newname=`echo $1 | sed 's/ \+/_/g'`
mv "$1" $newname

TIA
Patrick

--
gentoo-user@gentoo.org mailing list
Re: Find won't work always [ In reply to ]
Patrick Marquetecken wrote:

>Hi,
>
>Find give's me errors in some directories, i have created a little script for renaming about 3000 mp3 files (removing spaces from the file manes)
>I tested the find command in a directory with a dummy file and it works, now i'm going to test it on a real directory i get a error that my find syntax is wrong, but its always the same.
>Can anyone put some light on this, renaming that dir won't help.
>
>test dir (works)
>pwd = /home/patrick/rename_testen
>patrick@Inteprid rename_testen $ find . -name *.mp3 -exec ./ikke.sh '{}' \;
>
>real dir (don't work)
>pwd = /data/muziek/tunes
>patrick@Inteprid tunes $ find . -name *.mp3 -exec ./ikke.sh '{}' \;
>find: padnamen moeten de expressies voorgaan
>Gebruik: find [pad...] [expressie]
>
>works (but with false ikke.sh)
>pwd = /data/muziek
>patrick@Inteprid muziek $ find . -name *.mp3 -exec ./ikke.sh '{}' \;
>find: ./ikke.sh: Onbekend bestand of map (because ikke.sh isn't there, just for a test)
>
>the ikke.sh
>#/bin/bash
>#Purpose rename a file with spaces to underscores
>
>newname=`echo $1 | sed 's/ \+/_/g'`
>mv "$1" $newname
>
>TIA
>Patrick
>
>--
>gentoo-user@gentoo.org mailing list
>
>
>
>
>
>
find -iname '*.mp3' -exec ./ikke.sh '{}' \;

--

Adi


--
gentoo-user@gentoo.org mailing list
Re: Find won't work always [ In reply to ]
Adrian CAPDEFIER wrote:

>> Find give's me errors in some directories, i have created a little
>> script for renaming about 3000 mp3 files (removing spaces from the
>> file manes)
> find -iname '*.mp3' -exec ./ikke.sh '{}' \;

Aren't you going to tell him why?

you probably have spaces in your filenames, the '*.mp3' takes care of
the spaces.

--
gentoo-user@gentoo.org mailing list
Re: Find won't work always [ In reply to ]
> you probably have spaces in your filenames, the '*.mp3' takes care of
> the spaces.

...it also stops the shell from interpreting the "*" as a wildcard, as well...

--
gentoo-user@gentoo.org mailing list
Re: Find won't work always [ In reply to ]
On Fri, 22 Oct 2004 11:22:28 -0400
Billy <billy@gonoph.net> wrote:

> Adrian CAPDEFIER wrote:
>
> >> Find give's me errors in some directories, i have created a little
> >> script for renaming about 3000 mp3 files (removing spaces from the
> >> file manes)
> > find -iname '*.mp3' -exec ./ikke.sh '{}' \;
>
> Aren't you going to tell him why?
>
> you probably have spaces in your filenames, the '*.mp3' takes care of
> the spaces.
>
Indeed, but in all of those directories. Wy won't it work just in that one ??

Patrick

> --
> gentoo-user@gentoo.org mailing list
>
>
>

--
gentoo-user@gentoo.org mailing list
Re: Find won't work always [ In reply to ]
On 22 Oct 2004, at 11:56, Patrick Marquetecken wrote:
> On Fri, 22 Oct 2004 11:22:28 -0400 Billy <billy@gonoph.net> wrote:
>
>> Adrian CAPDEFIER wrote:
>>
>>>> Find give's me errors in some directories, i have created a little
>>>> script for renaming about 3000 mp3 files (removing spaces from the
>>>> file manes)
>>> find -iname '*.mp3' -exec ./ikke.sh '{}' \;
>>
>> Aren't you going to tell him why?
>>
>> you probably have spaces in your filenames, the '*.mp3' takes care of
>> the spaces.
>>
> Indeed, but in all of those directories. Wy won't it work just in that
> one ??
>
> Patrick

Because that isn't the problem.

Remember that the shell expands wildcards (like *) before find can get
to them. So, if you're in a directory containing MP3 files,

find . -iname *.mp3

would expand to

find . -iname twinkletwinkle.mp3 sonata.mp3

while, if you were in a directory without any MP3 files, the wildcard
would throw an error (because no such files exist).
Re: Find won't work always [ In reply to ]
Billy wrote:

> Adrian CAPDEFIER wrote:
>
>>> Find give's me errors in some directories, i have created a little
>>> script for renaming about 3000 mp3 files (removing spaces from the
>>> file manes)
>>
>> find -iname '*.mp3' -exec ./ikke.sh '{}' \;
>
>
> Aren't you going to tell him why?
>
> you probably have spaces in your filenames, the '*.mp3' takes care of
> the spaces.
>
yeah ... sorry ... I was in a rush and tried to type as quickly as possible.

--

Adi


--
gentoo-user@gentoo.org mailing list