[mdlug] batch name changes

Michael Mikowski z_mikowski at yahoo.com
Mon Jan 28 23:19:35 EST 2013


Hi Gary.  I just saw your post after a long day.  Here are your answers.




________________________________
 From: Garry Stahl <tesral at wowway.com>
To: MDLUG's Main discussion list <mdlug at mdlug.org> 
Sent: Monday, January 28, 2013 11:11 AM
Subject: Re: [mdlug] batch name changes
 
On 01/25/2013 08:24 AM, Mike Mikowski wrote:
> Hi Gary:
> 
> 1. #Open up a terminal
> 2. cd <directory with files>
> 3. pwd # to ensure you are in the right directory
> 4. # copy and paste
>   find ./ -type d |while read dir; do rename 's/$/.jpg/' $(find $dir -type f -maxdepth 1); done
> 5. # bask in success
> 

A few clarifications if you will.

find ./ -type

Is there anything I need to change in that?  The files in question have no extensions at all.  That seems to be the main issue for every GUI program I have tried to use.  It was a particularity of the Amiga that it read the file headers, extensions were unneeded and could frankly be wrong.  It didn't matter.

## no changes required.  In this case, we are checking for directories.

's/$/.jpg'

I can change that to any extension I desire?

## Absolutely.  If you want all GIF's use 's/$/.GIF'. :)

A side note: Only in perhaps the last 5-10 years has Unix/Linux become more dependent on file extensions.  Years ago when I used IRIX, file headers were used to distinguish file types almost exlusively (IIRC).  But Gnome and KDE have become more and more dependent on extensions which is a bit annoying sometimes.  On the other hand, I can see the alure: instead of having to probe each file, the system can simply look at the names and then get a mime-type from a simple lookup table. 


More information about the mdlug mailing list