The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Seems Complicated but would b happy if its possible anushree.a Shell Programming and Scripting 6 05-28-2008 06:25 AM
Sort complicated two fields lalelle Shell Programming and Scripting 3 04-17-2008 06:15 PM
complicated(?) grep khearnen UNIX for Dummies Questions & Answers 5 04-07-2008 01:03 PM
More complicated log parsing sjug Shell Programming and Scripting 25 06-13-2007 10:33 AM
Need help with complicated script (reading directories, extracting data) Gill Bates Shell Programming and Scripting 3 02-20-2007 07:05 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-08-2007
rocinante rocinante is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 21
Very complicated script..

I have a script that I need to create tha involves moving files and renaming them(see previous post)

Are there any websites with user made shell scripts?
  #2 (permalink)  
Old 06-08-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,958
Quote:
Originally Posted by rocinante
I have a script that I need to create tha involves moving files and renaming them(see previous post)

Are there any websites with user made shell scripts?

What is the previous post ?

Could you be even more specific with your requirement ?
  #3 (permalink)  
Old 06-08-2007
rocinante rocinante is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 21
Here are the details

Greetings,

I am new to scripting, but find if I can see the code working for a given problem, then I can eventually figure it out.

So, If ye dare, if yes be brave enough, then step forward to help me with this ---please.

I've just loaded a CD's worth of reference images. The images follow a naming scheme such as DSCN-1.JPG, DSCN-2.JPG ... DSCN-10.JPG, although the frame numbers may be noncontiguous (i.e., there may be gaps between numbers).

Although the frames were stored in separate directories on the
CD-ROM from which they were loaded, all of the frames have now been
placed into this directory:

/shots/roc/home/pix/out/home_test_v1/misc_bg8

The structure of the directory I've loaded them into is this:

/shots/$SHOWNAME/$SHOTNAME/pix/out/$ELEMENTNAME/$RESOLUTION_$COLORSPACE

I have to rename the frames in accordance with standard
naming conventions. These include:

1. No capital letters in the filenames

2. No dashes allowed in the filenames

3. The images should be re-numbered so that they are a contiguous
sequence (i.e. no gaps)

4. Frame numbers need to be padded to four-digits. ie, "1"
becomes "0001" This is denoted by the symbol # so a range of
1-240 would read 1-240#.

5. The frames should be renamed to match the directory in which
they are placed in the following manner:

$ELEMENTNAME_$RESOLUTION_$COLORSPACE.#.$EXTENSION

So, in other words, each frame should become:

/shots/roc/home/pix/out/home_test_v1/misc_bg8/home_test_v1_misc_bg8.0001.jpg
/shots/roc/home/pix/out/home_test_v1/misc_bg8/home_test_v1_misc_bg8.0002.jpg
/shots/roc/home/pix/out/home_test_v1/misc_bg8/home_test_v1_misc_bg8.0003.jpg
...
/shots/roc/home/pix/out/home_test_v1/misc_bg8/home_test_v1_misc_bg8.0240.jpg

However, the incoming frames are part of a series and must be kept in the exact same order as they were when loaded (i.e., the incoming frame with the lowest index will
map to `home_test_v1_misc_bg8.0001.jpg', while the second lowest index will map
to `home_test_v1_misc_bg8.0002.jpg', and so on). Hint: sorting by name is not enough!


Sample usage:
$ roc_cd2spi /shots/spi/home/pix/out/home_test_v1/misc_bg8
  #4 (permalink)  
Old 06-08-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,958
Quote:
So, If ye dare, if yes be brave enough, then step forward to help me with this ---please.
What does this mean ?

Try this,


Code:
#! /bin/zsh

typeset -l file

index=1
find . -name '*.*' -print | while read file
do
  mv $file `echo $file | sed 's/-//g'`"."$index
  index=$(($index + 1))
done

exit 0

  #5 (permalink)  
Old 06-08-2007
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,433
Thumbs down Duplicate thread


Code:
SIMPLE RULES OF THE UNIX FORUMS:

(4) Do not 'bump up' questions if they are not answered promptly. 
No duplicate or cross-posting and do not report a post or send a 
private message where your goal is to get an answer more quickly.

Initial thread : Move and rename files in seq. with padded digits

Jean-Pierre.
  #6 (permalink)  
Old 06-08-2007
rocinante rocinante is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 21
Thanks !!

I have been working on this for awhile.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:57 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0