rename in batch


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting rename in batch
# 1  
Old 03-08-2005
rename in batch

example test1 will have m1234567.12a
I would like to rename in batch but I don't Please help me on this.





cd /a1/a2/a3
test1=$(basename /a1/a2/a3/*.*) >> /tmp/t
echo $test1
echo "Extracting 8 th position" >> /tmp/t2
awk '{print substr($1,8,1); }' $test1 >> /tmp/t3
echo "extraction done" >> /tmp/t3
echo `date` "extract done timed " >> /tmp/t4


Thanks
kathy
# 2  
Old 03-08-2005
Plz. specify what do you exactly? I did not get you from your input.

# echo m1234567.12a | awk '{print substr($1,8,1); }' gives,
7

i.e if your test1 variable contains m1234567.12a string.

give more inputs so that your question will be solved.

hth.
# 3  
Old 03-08-2005
Using all those temporary files is a terrible way to script and should be avoided if at all possible.

As muthukumar indicates your example does not tell us what you are trying to do. Please provide a clear example of what you are trying to achieve.

i.e., are you trying to rename an entire directory of files according to some specific pattern?

This is what I would consider "renaming in batch"....

Code:
cd /path/to/files
ls | while read file; do
  mv ${file} `echo ${file} | sed 's/change_this/to_this/'`
done

There are more ways to tackle this problem but we need a lot more information to be able to assist further.

Thanks,
ZB
# 4  
Old 03-09-2005
ls *.* | (made to cmd) | sh
or
find ./ *.* | xargs -i mv {} {}.bak
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Batch or not if/then

I am having trouble modifying a .sh that allows the user to run different command based of an input. So based on the user input of Y or N a different command is run. Thank you :). #!/bin/bash while true do printf "Is this a batch : " ; read id && break If "$id" = Y, Then... (14 Replies)
Discussion started by: cmccabe
14 Replies

2. Shell Programming and Scripting

Batch Script To Unzip and Rename File

Hello All, I need help in writing a batch script. I have 100 zip files in a folder. Each zip file has a unique name starting with XYZ_12345.zip Each zip file contains single csv file I would like to batch extract the files and also rename the extracted csv as per the original zip name... (6 Replies)
Discussion started by: rajlakshmi
6 Replies

3. Shell Programming and Scripting

Batch download

............. (9 Replies)
Discussion started by: hoo
9 Replies

4. Shell Programming and Scripting

Executing a batch of files within a shell script with option to refire the individual files in batch

Hello everyone. I am new to shell scripting and i am required to create a shell script, the purpose of which i will explain below. I am on a solaris server btw. Before delving into the requirements, i will give youse an overview of what is currently in place and its purpose. ... (2 Replies)
Discussion started by: goddevil
2 Replies

5. Shell Programming and Scripting

Batch rename files that do not match pattern

Hi all, I do not have programming experience and mostly use one-liner or sometimes more to get the job done. I am having problem to batch rename the files that do not match a particular pattern. Sample file-names from directory: Meeting_Packages.pdf 13_textfile0 19_textfile0 ... (3 Replies)
Discussion started by: atulkakrana
3 Replies

6. Shell Programming and Scripting

try to batch rename using sed (if this is best)

hi gooday I need some help with a rename I am attempting. I'd like to rename a bunch of files in a folder example list.dat.old to list_N.dat query.dat.old to query_N.dat note the two periods in (.dat.old) to become _N.dat I tried using sed like this ls *.dat.old | sed... (3 Replies)
Discussion started by: johnstrong
3 Replies

7. Shell Programming and Scripting

Batch rename files after internal search pattern

Hello all I am trying to do a script that would allow me to mass rename files after a grep search within them. They are XML files and the pattern I would like to append to the file name is easy to find (e.g. <filename>foo</filename>), but I can't for the life of me find out how to do it and... (2 Replies)
Discussion started by: aavv
2 Replies

8. UNIX for Advanced & Expert Users

batch file

Hi all I am using tru64 Unix and I want a ready batch file which makes me to change all user passwords at the same time ,instead of changing everyone separately. Please could anyone help me to do that. bye. (1 Reply)
Discussion started by: ahmedbashir
1 Replies

9. UNIX for Dummies Questions & Answers

Batch rename recursively

I would like to replace multiple underscores with hyphens but I have 26,000 files to rename. They are all in one file structure and multiple sub-directories. It would be much simpler if I had a script to do it. Here are some samples of the file names: Example 1... (3 Replies)
Discussion started by: ..Chris..
3 Replies

10. UNIX for Advanced & Expert Users

rename the file in batch

In my dir there are files like a.xml b.xml abnc.xml 12.abc.xml 12.anc.sfoioi.xml I need to remove .xml from all the files Is there any direct way without using any for/do loop Right now i am using for file in * do ... (7 Replies)
Discussion started by: reldb
7 Replies
Login or Register to Ask a Question