Change name of multiple files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Change name of multiple files
# 1  
Old 11-22-2013
Change name of multiple files

Hi Guys

Please can you help me.

I have a lot of files whit wrong name

example
Code:
00000500_001.segd
00000501_001.segd
00000502_001.segd
00000503_001.segd
00000504_001.segd

I would like to remove _001 in all files

So, the files shouldbe
Code:
00000500.segd
00000501.segd
00000502.segd
00000503.segd
00000504.segd

Thansk a lot for your help

Last edited by jiam912; 11-22-2013 at 12:07 PM.. Reason: Please use code tags
# 2  
Old 11-22-2013
Try:
Code:
rename s/_001// *segd

Or
Code:
 
for f in *.segd ; do mv $f ${f/_001/} ; done

This User Gave Thanks to Subbeh For This Post:
# 3  
Old 11-22-2013
Thanks a lot

Quote:
Originally Posted by Subbeh
Try:
Code:
rename s/_001// *segd

Or
Code:
 
for f in *.segd ; do mv $f ${f/_001/} ; done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep strings on multiple files and output to multiple files

Hi All, I want to use egrep on multiple files and the results should be output to multiple files. I am using the below code in my shell script(working in Ksh shell). However with this code I am not attaining the desired results. #!/bin/ksh ( a="/path/file1" b="path/file2" for file in... (4 Replies)
Discussion started by: am24
4 Replies

2. UNIX for Dummies Questions & Answers

Run one script on multiple files and print out multiple files.

How can I run the following command on multiple files and print out the corresponding multiple files. perl script.pl genome.gff 1.txt > 1.gff However, there are multiples files of 1.txt, from 1----100.txt Thank you so much. No duplicate posting! Continue here. (0 Replies)
Discussion started by: grace_shen
0 Replies

3. UNIX for Dummies Questions & Answers

Want to change common line from multiple files

Hi everyone, I've a requirement to modify an existing line which is common to multiple files. I need to replace that existing line with a new line. I've almost 900 ksh files to edit in the similar fashion in the same directory. Example: Existing Line: . $HOME/.eff.env (notice the "." at the... (3 Replies)
Discussion started by: kaleem.adil
3 Replies

4. Shell Programming and Scripting

Change the content of files but not change the date

I have 100 files in a directory , all the files have a word "error" and they are created in different date . Now I would like to change the word from "error" to "warning" , and keep the date of the files ( that means do not change the file creation date after change the word ) , can advise what can... (7 Replies)
Discussion started by: ust3
7 Replies

5. Shell Programming and Scripting

Change the content of files but not change the date

I have 100 files in a directory , all the files have a word "error" and they are created in different date . Now I would like to change the word from "error" to "warning" , and keep the date of the files ( that means do not change the file creation date after change the word ) , can advise what can... (0 Replies)
Discussion started by: ust3
0 Replies

6. Shell Programming and Scripting

awk, multiple files input and multiple files output

Hi! I'm new in awk and I need some help. I have a folder with a lot of files and I need that awk do something in each file and print a new file with the output. The input file name should be modified when I print the outpu files. Thanks in advance for help! :-) ciao (5 Replies)
Discussion started by: gabrysfe
5 Replies

7. UNIX for Dummies Questions & Answers

Change lines in multiple files

Hi. I have a folder with a large number of files and would like to apply the following changes to each line in each of the files: sed 's/$/\/Q:_0/' I wrote a loop, but it just changes the name of the file, not the contents of the file: for i in ./dir/*.lab do sed 's/$/\/Q:_0/'... (1 Reply)
Discussion started by: Bloomy
1 Replies

8. UNIX for Dummies Questions & Answers

Using AWK: Extract data from multiple files and output to multiple new files

Hi, I'd like to process multiple files. For example: file1.txt file2.txt file3.txt Each file contains several lines of data. I want to extract a piece of data and output it to a new file. file1.txt ----> newfile1.txt file2.txt ----> newfile2.txt file3.txt ----> newfile3.txt Here is... (3 Replies)
Discussion started by: Liverpaul09
3 Replies

9. UNIX for Dummies Questions & Answers

change name of multiple files in a same folder

I searched and tried many answers from similar questions on this forum, but none of them finished my job. Maybe I am too novice to unix. Sorry I have to ask again,and hope I can get the answer. I have a folder with files sqcu001v.jpg, sqcu002v.jpg, ... sqcu100v.jpg. I want to have... (3 Replies)
Discussion started by: softmud
3 Replies

10. Shell Programming and Scripting

rsh to change multiple ip in multiple servers?

good day. i jsut wanted to know what is the best script or the best way changing a lot of Ip's in all servers. Do you have any idea? im using awk to change IP,what if, you have lots of servers. You need to change it one by one? It will take time to change it manually. (2 Replies)
Discussion started by: kenshinhimura
2 Replies
Login or Register to Ask a Question