[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bulk filename changes



Hi Jason,

  I don't have a one liner to do it with, although I'm pretty sure you could do this with sed/awk quite easily, but I'm being kinda lazy here tonight. 

This is how I've done it before in the past using KSH 

#!/usr/bin/ksh

files=`ls *jpg.in.out`

for i in $files
do
  oldfilename=`echo $i`
  newfilename=`echo $oldfilename|cut -d. -f1-2`

  echo "moving \"$oldfilename\" to \"$newfilename\""
  mv $oldfilename $newfilename
done

You don't have to have the echo statements , unless you'd like to see what the script is doing . 

HTH 

Roger K. Hill
A+, Network+, SCO CSA, SCSA (Solaris 8.0) 
  
============================================================
From: Jason V Smith <jvsmith@midamer.net>
Date: 2005/01/19 Wed PM 05:34:00 CST
To: SILUG Discuss <silug-discuss@silug.org>
Subject: bulk filename changes

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
-- 
Jason Smith 
jvsmith at midamer dot net


-
To unsubscribe, send email to majordomo@silug.org with
"unsubscribe silug-discuss" in the body.
============================================================



-
To unsubscribe, send email to majordomo@silug.org with
"unsubscribe silug-discuss" in the body.