Re: changing extensions, a little OT perhaps.
On Fri, Apr 26, 2002 at 01:32:33PM -0400, Bob Torres wrote:
> Hi All,
>
> I recently transferred some MP3s from my MacOS desktop to my Debianppc
> laptop. There are no file extensions for these mp3 files, so they're
> kind worthless for xmms in Linux.
>
> On the Linux side, how would I go about adding extensions to these files
> without doing it manually? In other words, is there something I could
> pass at the command line to accomplish this for a whole directory of
> files?
If the directory with the mp3s contains only misnamed MP3s, and assuming
a Bourne shell:
$ for i in *; do mv "$i" "$i.mp3"; done
or, (mostly) regardless of shell
$ find . -type f -exec mv {} {}.bak \;
If other non-MP3 files are present in the directory:
$ for i in *; do if file "$i" | grep -q MPEG; then mv "$i" "$i.mp3"; fi; done
or (probably overkill):
$ find . -type f -exec sh -c 'file {} | grep -q MPEG' \; -exec mv {} {}.mp3 \;
Add a '-maxdepth 1' between '.' and '-type' on the commands using find
if you only want them to rename files in the current directory -
otherwise, they recurse to any subdirectories.
> I've been using Linux for three years or so now, and I've always
> wanted to know how to do this...anyone care to educate me? I'm hoping
> for something a little more substantive than "go learn sed (or whatever
> program)," though learning by example usually works the best for me. ; )
--
William Aoki waoki@umnh.utah.edu /"\ ASCII Ribbon Campaign
3B0A 6800 8A1A 78A7 9A26 BB92 \ / No HTML in mail or news!
9A26 BB92 6329 2D3E 199D 8C7B X
/ \
--
To UNSUBSCRIBE, email to debian-powerpc-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Reply to: