FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Fedora User

 
 
LinkBack Thread Tools
 
Old 06-20-2008, 04:06 PM
"Daniel B. Thurman"
 
Default 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
 
Old 06-20-2008, 04:53 PM
John Cornelius
 
Default 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
 
Old 06-20-2008, 05:06 PM
Robert Nichols
 
Default 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
 
Old 06-20-2008, 05:36 PM
"Patrick O'Callaghan"
 
Default 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
 
Old 06-20-2008, 09:35 PM
Robert Nichols
 
Default 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
 
Old 06-20-2008, 10:02 PM
"Patrick O'Callaghan"
 
Default 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
 
Old 06-21-2008, 12:32 AM
john wendel
 
Default 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
 

Thread Tools




All times are GMT. The time now is 07:33 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org