Hi Guys,
I have a small problem of renaming multiple files. For example I have names of a set of files in one directory like
and the other set corresponding to the same is
Now what I would like is that the new renamed file looks like this so that it computes the mean of the last two values in first set ; for example
K2_34625-34675 should become K2_34650 and so on for the other names in the first set,
then these new names have to be used to rename the second set of files for example ;
U_P_321_9_3_11.ab1 should become K2_36450.ab1, and so on.
Could anyone please help out on this as I have a long list like this.
Hope to get some answers
Thanx in advance
Pawan
Moderator's Comments:
Please use code tags when posting data and code samples!
---------- Post updated 03-11-11 at 04:30 AM ---------- Previous update was 03-10-11 at 04:02 PM ----------
Thank you moderator for correcting my input .... I was not aware of such a thing as code tag.
Hope now the input is OK for a reply from the forum.
Looking forward to it .... Thanks in advance
Last edited by vgersh99; 03-10-2011 at 05:05 PM..
Reason: code tags, please!
If it does what you want then just change the echo "mv $a $n" with mv "$a $n"
---------- Post updated at 12:42 AM ---------- Previous update was at 12:34 AM ----------
please give more clue about the caculation for the renaming :
34625-34675 = -50
and what should be calculated in the
773882-7734102
????
I assumed you want to keep the first 3 number unchanged so that is becomes:
-(882-4102)=3220
so the new name will be K12_7733220.ab1
by the way, i also assume you have the same number of entries in your both set of files
Thanks CTSGNB,
Your suggestion is producing the exact output as you mentioned, but my expected outcome for input is as follows
output before calculation
K2_34625-34675.ab1
For the calculation I want to calculate the mean of the two numbers separated by "-" which does not imply subtraction. Thus my final expected output for each entry in both set of files should be for example:
K2_34650.ab1
Please not the one set of entries are just assigned names eg. K2_34625-34675 upon which the calculation need to be done and then assigned the modified name to another entry (those ending with .ab1) which are real data containing files to be renamed.
I tried your code but its giving me the following output:
but when I remove the "" in the mv command I get
Is this because a.txt and b.txt in this case are files containing entries and not real .ab1 files ??
I will do this will real files soons and let you know but if you can comment on the code to simplfy what its doing its will be a big help. At the moment I dont understand it
Hi, I have about 60 files in a directory and need to rename those files. For example the file names are
i_can_phone_yymmdd.txt (where yymmdd is the date. i.e 170420 etc)
i_usa_phone_1_yymmdd.txt
i_eng_phone_4_yymmdd.txt
The new file names should be
phone.txt
phone_1.txt
phone_4.txt
I am... (4 Replies)
Data files coming in different names in a file name called process.txt.
1. shipments_yyyymmdd.gz
2 Order_yyyymmdd.gz
3. Invoice_yyyymmdd.gz
4. globalorder_yyyymmdd.gz
The process needs to discard all the below files and only process two of the 4 file names available
... (1 Reply)
Hi Team,
I'm new to Unix shell scripting .
I've the following requirement
A folder contains the list of files with the following format
ab.name.11.first
ab.name.12.second
ab.name.13.third
----------
I have to rename the above file to like below
... (6 Replies)
I have hundreds of files with weird names, something like this:
I was wondering how can I rename them all keeping the sampleid and the last extension, something like this:
Any help will be greatly appreciated. (5 Replies)
Hi there,
Firstly, I have no experience with shell scripts so would really appreciate some help.
I have the following shell script that is causing some problems:
moveit()
{
&& set -x
if
then
DOUBLE_DELIVERY=$(grep... (6 Replies)
I have 7 files with 7 different names coming into a specified folder on weekly basis, i need to pick a file one after another and load into oracle table using sql loader. I am using ksh to do this. So in the process if the file has error records and if sql loader fails to load into oracle tables,... (2 Replies)
I haven’t used Unix in over 25 years … and so I am at a loss for something that should be very simple. I have a lot of jpeg files (i.jpg) of students in a yearbook.. I also have an array name(i) of their names. I need to rename each “i.jpg” to “name(i).jpg”. I believe the ksh script... (11 Replies)
I have to rename a large number of files so that the name of each file corresponds to a code number that is given side by side in a list (textfile).
The list contains in column A the filename of the actual files to be renamed and in column B the name (a client code, 9 digits) that has to be... (7 Replies)
I have a file that looks like this
2 4 10 500 tim9
5 8 14 700 tim9
3 5 15 432 john1
1 4 12 999 ellen2
So basically what i want to do is fine duplicate names on column 5 and rename it with an extention (i.e. tim9_1 and tim9_2).
so the output file will look like this
2 4 10 500 tim9_1... (1 Reply)
I want to write a shell script that will rename all the file names to today's date attached to it..
so for example i have a file names like
file1.sales.20081201.txt.c
zbrs.salestxtn.20091101.txt.inn
then it will rename both the files with todays date to it so the file names get changed... (1 Reply)