[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bulk filename changes BASH sed solution...
If you are on a fedora/redhat system, there is an rpm called util-linux
which has a command /usr/bin/rename. The sequence looks like:
[erich@groucho temp]$ touch pb040016.jpg.in.out
[erich@groucho temp]$ ls -l pb*
-rw-rw-r-- 1 erich erich 0 Jan 20 14:45 pb040016.jpg.in.out
[erich@groucho temp]$ rename jpg.in.out jpg *.in.out
[erich@groucho temp]$ ls -l pb*
-rw-rw-r-- 1 erich erich 0 Jan 20 14:45 pb040016.jpg
eks
On Thu, 20 Jan 2005, Ken Keefe wrote:
> This is the best way I know of doing it. Not that that necessarily means
> much... Anyway, here is the BASH script...
>
> #!/bin/sh
> for i in *.jpg.in.out
> do
> mv "$i" "`echo $i | sed 's/.in.out//'`"
> done
>
> Or, you can do that right at the command prompt on one line like so
> (given that you are using BASH):
>
> for i in *.jpg.in.out; do mv "$i" "`echo $i | sed 's/.in.out//'`"; done
>
> Good luck...
>
> Ken
>
>
>
> On Wed, 2005-01-19 at 17:34 -0600, Jason V Smith wrote:
>> Good evening,
>>
>> I'm stumped not sure where to look. Here's what I want to do. I have a
>> bunch of pictures that are named similar to this pb040016.jpg.in.out.
>> What I want is to rename the file to this pb040016.jpg. But I have a
>> bunch of files like this. I know this is probably pretty simple but I'm
>> not sure what command(s) could help. My only stipulation, if at all
>> possible, is to not use perl/python/sed or awk. But feel free to offer
>> up perl one-liners that would do this. It will help further what little
>> (I emphasize little) perl knowledge that I have.
>>
>> Your help is greatly appreciated.
>>
>> Jason
>
>
> -
> To unsubscribe, send email to majordomo@silug.org with
> "unsubscribe silug-discuss" in the body.
>
---------------------------------------------------------------------
Erich Schroeder Phone: (217)785-0033
Curator, Information Technologies FAX: (217)785-2857
Illinois State Museum GIS Lab email:erich(at)illinois.state.museum
http://illinois.state.museum/
---------------------------------------------------------------------
-
To unsubscribe, send email to majordomo@silug.org with
"unsubscribe silug-discuss" in the body.