Very complicated script..


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Very complicated script..
# 1  
Old 06-08-2007
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  
Old 06-08-2007
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  
Old 06-08-2007
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  
Old 06-08-2007
Quote:
So, If ye dare, if yes be brave enough, then step forward to help me with this ---please.
What does this mean ? Smilie

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  
Old 06-08-2007
PHP 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  
Old 06-08-2007
Thanks !!

I have been working on this for awhile.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Assistance on complicated perl script

As a followup to my previous thread, I'm trying to make a complicated perl script that involves storing information from a text file into a hash, and giving the user the ability to change the information present/write the information currently inside the hash to a new file. This is the code I've... (8 Replies)
Discussion started by: Eric1
8 Replies

2. Shell Programming and Scripting

Help on a fairly complicated shell script

Hello, also with the help of some great users of this forum, I have created following shell script. MM=120 GG=5000 # get size of directory szm=$(du -s --block-size M ./192.168.1.xxx | awk '{print int($0)}') data=$(date --rfc-3339=seconds) if ; then # too big delete older files ... (10 Replies)
Discussion started by: dcaccount
10 Replies

3. Shell Programming and Scripting

Complicated string

I have a data file example 10302|77747373|442422442|290209|244242|"234|2352"|92482892 It has about 5000 rows the same way in that field. Needs to look like this.... I need to remove the quotes but the more difficult thing is to remove the pipe between the quotes because there is a pipe... (6 Replies)
Discussion started by: xgringo
6 Replies

4. Solaris

Solaris? Is it really this complicated?

Hello Everybody, I am a mid-level Linux administrator trying to get a hold of Solaris. So far, my experience has been painful. I think it's confusing and it's just a big mess... To be more specific, I have noticed that whenever I install a package... it never followed a specific pattern.... (4 Replies)
Discussion started by: EssenceNY
4 Replies

5. Shell Programming and Scripting

Script Search replace - complicated

I have a text file for which i need a script which does some fancy search and replace. Basically i want to loop through each line, if i find an occurance of certain string format then i want to carry on search on replace another line, once i replaced this line i will contine to search for the... (7 Replies)
Discussion started by: kelseyh
7 Replies

6. Shell Programming and Scripting

need help with script - output to file, but complicated

ok, so what i want to do is make a script that will do the following: take out from a command in the terminal put that output into a text file already on my computer. the only thing is that i need to put the output in the file kinda weird: i need to take it and put each character of output... (13 Replies)
Discussion started by: twoodcc
13 Replies

7. Shell Programming and Scripting

Seems Complicated but would b happy if its possible

Hey guys, I m here again with (may b) a silly query n sorry for that, I am new to UNIX n all so don't kno much @ it. Thro' a script I am generating an output (It is a TXT file) After generating it, I get it to windows n mails it by dragging n dropping it in lotus mail new mail window. Is there... (6 Replies)
Discussion started by: anushree.a
6 Replies

8. UNIX for Dummies Questions & Answers

complicated(?) grep

Hi all, I need help to figure out this grep. I would like to search all files in a directory for the occurrence of abc AND xyz. I started with this: grep -i abc * | grep xyz But this only returns lines which contain both values on the same line. So I am thinking that I need to do... (5 Replies)
Discussion started by: khearnen
5 Replies

9. Shell Programming and Scripting

More complicated log parsing

Hey Guys, I am trying to grep within a file to find and output certain parts of lines to other file(s). The output files need to have a dynamic file name based on a field in the main log. The problem is that every line of the log is not the same, and often not even similar. To explain... (25 Replies)
Discussion started by: sjug
25 Replies

10. Shell Programming and Scripting

Need help with complicated script (reading directories, extracting data)

Hi, people. I was searching script tutorials/examples and found this forum, and thought to ask for help, because there seems to be many wise people here. (Try to bare with me, I'm a Windows user, so this stuff is somewhat strange to me, OK? :rolleyes: ) Anyways, I need to create a script that... (3 Replies)
Discussion started by: Gill Bates
3 Replies
Login or Register to Ask a Question