Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Fedora User (http://www.linux-archive.org/fedora-user/)
-   -   Using FIND to globally rename files... (http://www.linux-archive.org/fedora-user/110442-using-find-globally-rename-files.html)

"Daniel B. Thurman" 06-20-2008 04:06 PM

Using FIND to globally rename files...
 
How do you use FIND to globally rename files?

I find that some music files that have '!' embedded in them
to cause conflicts especially when attempting to use
Nautilus to move them from one location into another,
so I wish to rename files that have offending characters
in them.

I tried:

1) find . -type f -name *.mp3 -exec mv "{}" `echo "{}" | sed -e
's/[!]//`" ;

Nope. Does not work.

2) find . -type f -name *.mp3 | xargs "echo "mv "{}" `echo "{}" |
sed -e 's/!//`""
Ah, this is really convoluted, of course it does not work. It is
rife with errors indeed!

:)

Um, help!?!?

Kind regards,
Dan

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list

John Cornelius 06-20-2008 04:53 PM

Using FIND to globally rename files...
 
Daniel B. Thurman wrote:


How do you use FIND to globally rename files?

I find that some music files that have '!' embedded in them
to cause conflicts especially when attempting to use
Nautilus to move them from one location into another,
so I wish to rename files that have offending characters
in them.

I tried:

1) find . -type f -name *.mp3 -exec mv "{}" `echo "{}" | sed -e
's/[!]//`" ;

Nope. Does not work.

2) find . -type f -name *.mp3 | xargs "echo "mv "{}" `echo "{}" |
sed -e 's/!//`""
Ah, this is really convoluted, of course it does not work. It is
rife with errors indeed!

:)

Um, help!?!?

Kind regards,
Dan
Nope! You get to execute one and only one command in a find statement
but that can be a shell script. You might try putting your pipe into a
script and then executing the script with the find.


John Cornelius

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list

Robert Nichols 06-20-2008 05:06 PM

Using FIND to globally rename files...
 
Daniel B. Thurman wrote:


How do you use FIND to globally rename files?

I find that some music files that have '!' embedded in them
to cause conflicts especially when attempting to use
Nautilus to move them from one location into another,
so I wish to rename files that have offending characters
in them.

I tried:

1) find . -type f -name *.mp3 -exec mv "{}" `echo "{}" | sed -e
's/[!]//`" ;

Nope. Does not work.

2) find . -type f -name *.mp3 | xargs "echo "mv "{}" `echo "{}" |
sed -e 's/!//`""
Ah, this is really convoluted, of course it does not work. It is rife
with errors indeed!

:)


Yes, the second has serious problems with nesting of quotes. Simplest
way is to use the 'rename' command:

find . -type f -name '*!*.mp3' -exec rename '!' ' {} ;

--
Bob Nichols "NOSPAM" is really part of my email address.
Do NOT delete it.

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list

"Patrick O'Callaghan" 06-20-2008 05:36 PM

Using FIND to globally rename files...
 
On Fri, 2008-06-20 at 12:06 -0500, Robert Nichols wrote:
> Daniel B. Thurman wrote:
> >
> > How do you use FIND to globally rename files?
> >
> > I find that some music files that have '!' embedded in them
> > to cause conflicts especially when attempting to use
> > Nautilus to move them from one location into another,
> > so I wish to rename files that have offending characters
> > in them.
> >
> > I tried:
> >
> > 1) find . -type f -name *.mp3 -exec mv "{}" `echo "{}" | sed -e
> > 's/[!]//`" ;
> > Nope. Does not work.
> >
> > 2) find . -type f -name *.mp3 | xargs "echo "mv "{}" `echo "{}" |
> > sed -e 's/!//`""
> > Ah, this is really convoluted, of course it does not work. It is rife
> > with errors indeed!
> > :)
>
> Yes, the second has serious problems with nesting of quotes. Simplest
> way is to use the 'rename' command:
>
> find . -type f -name '*!*.mp3' -exec rename '!' ' {} ;

Slightly better:

find . -type f -name '*!*.mp3' -print0 |xargs -0 rename '!' '

This will work even for filenames with spaces in them (quite common with
music files).

poc

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list

Robert Nichols 06-20-2008 09:35 PM

Using FIND to globally rename files...
 
Patrick O'Callaghan wrote:

On Fri, 2008-06-20 at 12:06 -0500, Robert Nichols wrote:

Simplest
way is to use the 'rename' command:

find . -type f -name '*!*.mp3' -exec rename '!' ' {} ;


Slightly better:

find . -type f -name '*!*.mp3' -print0 |xargs -0 rename '!' '

This will work even for filenames with spaces in them (quite common with
music files).


As will the command I suggested. Arguments to commands invoked by
"-exec" are passed WITHOUT being parsed by a shell.

--
Bob Nichols "NOSPAM" is really part of my email address.
Do NOT delete it.

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list

"Patrick O'Callaghan" 06-20-2008 10:02 PM

Using FIND to globally rename files...
 
On Fri, 2008-06-20 at 16:35 -0500, Robert Nichols wrote:
> Patrick O'Callaghan wrote:
> > On Fri, 2008-06-20 at 12:06 -0500, Robert Nichols wrote:
> >> Simplest
> >> way is to use the 'rename' command:
> >>
> >> find . -type f -name '*!*.mp3' -exec rename '!' ' {} ;
> >
> > Slightly better:
> >
> > find . -type f -name '*!*.mp3' -print0 |xargs -0 rename '!' '
> >
> > This will work even for filenames with spaces in them (quite common with
> > music files).
>
> As will the command I suggested. Arguments to commands invoked by
> "-exec" are passed WITHOUT being parsed by a shell.

Fair enough.

poc

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list

john wendel 06-21-2008 12:32 AM

Using FIND to globally rename files...
 
Daniel B. Thurman wrote:


How do you use FIND to globally rename files?

I find that some music files that have '!' embedded in them
to cause conflicts especially when attempting to use
Nautilus to move them from one location into another,
so I wish to rename files that have offending characters
in them.

I tried:

1) find . -type f -name *.mp3 -exec mv "{}" `echo "{}" | sed -e
's/[!]//`" ;

Nope. Does not work.

2) find . -type f -name *.mp3 | xargs "echo "mv "{}" `echo "{}" |
sed -e 's/!//`""
Ah, this is really convoluted, of course it does not work. It is rife
with errors indeed!

:)

Um, help!?!?

Kind regards,
Dan



You might want to check this program. I use it all the time ...

http://sourceforge.net/projects/detox

Regards,

John

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list


All times are GMT. The time now is 11:47 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.