Rename all files at a time


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Rename all files at a time
# 1  
Old 03-26-2013
Rename all files at a time

i have some bar files in a directory

Code:
appp1.APP.RTP.DEV1
appp2.APP.RTP.DEV1
appp3.APP.RTP.DEV1


need to be renamed as

Code:
appp1.APP.mmk.DEV1
appp2.APP.mmk.DEV1
appp3.APP.mmk.DEV1

i need to rename all files at a time.

Last edited by Scrutinizer; 03-26-2013 at 03:04 AM.. Reason: code tags
# 2  
Old 03-26-2013
Can you search the forum
# 3  
Old 03-26-2013
Code:
$ ls -1
appp1.APP.RTP.DEV1  
appp2.APP.RTP.DEV1  
appp3.APP.RTP.DEV1

Code:
$ rename 's/RTP/mmk/' appp*.APP.RTP.DEV1

Code:
$ ls -1
appp1.APP.mmk.DEV1  
appp2.APP.mmk.DEV1  
appp3.APP.mmk.DEV1

Code:
$ uname -a
Linux lark 2.6.32-21-generic-pae #32-Ubuntu SMP Fri Apr 16 09:39:35 UTC 2010 i686 i686 i686 GNU/Linux


Last edited by hanson44; 03-26-2013 at 02:20 AM.. Reason: Add Linux version
# 4  
Old 03-26-2013
Hello hanson44,

It's not working Smilie

Below is my output:
Code:
[root@dhcppc116 files]# ls
appp1.APP.RTP.DEV1  appp2.APP.RTP.DEV1  appp3.APP.RTP.DEV1
[root@dhcppc116 files]# rename 's/RTP/mmk' *.DEV1
[root@dhcppc116 files]# ls
appp1.APP.RTP.DEV1  appp2.APP.RTP.DEV1  appp3.APP.RTP.DEV1
[root@dhcppc116 files]# 

[root@dhcppc116 ~]# uname -a
Linux dhcppc116 2.6.18-92.el5 #1 SMP Tue Apr 29 13:16:12 EDT 2008 i686 i686 i386 GNU/Linux

# 5  
Old 03-26-2013
Maybe the following glitch?
Code:
rename 's/RTP/mmk' *.DEV1

vs

rename 's/RTP/mmk/' *.DEV1

Or maybe you just made an error when you copied and pasted?
# 6  
Old 03-26-2013
I will try that , anyway i solved it by following code :

Code:
for i in *.DEV1
do
fname1=`basename $i .RTP.DEV1`
mv "$i" "$fname1.mmk.DEV1"
done

Thanks!!
# 7  
Old 03-26-2013
Yes, the short shell script is a fine way.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SBATCH trinity for multiple files and rename/move the output files

Hey guys, I have wrote the following script to apply a module named "trinity" on my files. (it takes two input files and spit a trinity.fasta as output) #!/bin/bash -l #SBATCH -p node #SBATCH -A <projectID> #SBATCH -n 16 #SBATCH -t 7-00:00:00 #SBATCH --mem=128GB #SBATCH --mail-type=ALL... (1 Reply)
Discussion started by: @man
1 Replies

2. Shell Programming and Scripting

How to rename all files at a time by appending some characters at the begining?

Hi I have a list a filename in a directory starting with particular pattern for example: abc_1234.txt abc_7565.txt abc_7676.txt abc_7765.txt i need to rename all these files by appending bck. or bck_ Expected output: bck.abc_1234.txt bck.abc_7565.txt bck.abc_7676.txt... (1 Reply)
Discussion started by: Little
1 Replies

3. Shell Programming and Scripting

Script to unzip files and Rename the Output-files

Hi all, I have a many folders with zipped files in them. The zipped files are txt files from different folders. The txt files have the same names. If i try to find . -type f -name "*.zip" -exec cp -R {} /myhome/ZIP \; it fails since the ZIP files from different folders have the same names and... (2 Replies)
Discussion started by: pmkenya
2 Replies

4. Shell Programming and Scripting

Need bash script to ping the servers and rename the output file each time the script is ran

HI, I have a file serverlist in that all host names are placed. i have written a small script #./testping #! /bin/bash for i in `cat serverlist` do ping $i >> output.txt done so now it creates a file output.txt till here fine.. now each time i run this script the output file... (4 Replies)
Discussion started by: madhudeva
4 Replies

5. Shell Programming and Scripting

If(Condition) Rename a file with (Date+Time) Stamp

Hi! Please see our current script: #!/usr/bin/ksh if (egrep "This string is found in the log" /a01/bpm.log) then mailx -s "Error from log" me@email.com, him@email.com </a01/bpm.log fi To the above existing script, we need to add the following change: 1) After finding the string,... (7 Replies)
Discussion started by: atechcorp
7 Replies

6. Linux

rename files in a folder with date&time stamp

Hi, I want to rename all the files (more than 100 files) in a fodler to another folder with date&time stamp. foe eg, file1.dat file2.dat file3.dat .. to be renamed as file1100629_16_30_15.txt (yy-mon-dd_hh_mi_ss) file1100629_16_30_16.txt .. so on (2 Replies)
Discussion started by: feroz
2 Replies

7. Shell Programming and Scripting

Rename files

Hi, I am new to Unix and i have a requirement where i need to write a shell script where i have to loop through various files present in a directory and rename them based on below criteria. Files in the folder are in the following format. _YYYYMMDD.dat] SDL_V1_20100530.dat... (6 Replies)
Discussion started by: bishoo
6 Replies

8. Shell Programming and Scripting

rename files Ax based on strings found in files Bx

Hi, I'm not very experienced in shell scripting and that's probably why I came across the following problem: I do have several hundred pairs of text files (PF00x.spl and PF00x.shd) where the first file (PF00x.spl) needs to be renamed according a string that is included in the second file... (12 Replies)
Discussion started by: inCH
12 Replies

9. Shell Programming and Scripting

Rename files

Hi, I wanna rename bunch of files which has ":" to -. ie. rename file named file1:file1 to file1-file1. any ideas? (2 Replies)
Discussion started by: linuxaddict7
2 Replies

10. UNIX for Dummies Questions & Answers

How to rename files?

:confused: How can i rename a file 'x.log' to 'x_20020512 072909.log' :eek: i'm using perl, with system command from a unix web server, and need to timestamp my logs if the above format (filename _ year month day hr min sec .log) (9 Replies)
Discussion started by: CompuTelSystem
9 Replies
Login or Register to Ask a Question