rename file, add extensions


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting rename file, add extensions
# 1  
Old 02-05-2012
Bug rename file, add extensions

Hi Guys,

I have files named myfileaa,myfileab,myfileac,myfilesad.... till myfileav.

Now i needs to rename all these files to myfileaa.txt ,myfileab.txt,myfileac.txt.


Please help me how to do the same.

Thanks in advance..!!!
# 2  
Old 02-05-2012
Are you sure that those have not been generated from the use of the split command ?

If so, you should rebuild the initial big file that has been splitted into smaller files with suffix aa ab ac ad ... by concatenating them.
# 3  
Old 02-05-2012
I have splitted all these files using split command, but the new files dnt hve the .txt extension...

that is the problem..!!!
# 4  
Old 02-05-2012
What split command did you use ? (with which options) ?

---------- Post updated at 10:15 PM ---------- Previous update was at 10:14 PM ----------

Code:
for i in myfile*
do
mv "$i" "$i.txt"
done

# 5  
Old 02-05-2012
Quote:
Originally Posted by jaituteja
Hi Guys,

I have files named myfileaa,myfileab,myfileac,myfilesad.... till myfileav.

Code:
for d in myfilea{a..v}; do mv ${d}{,.txt};done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Add file extensions to files EXCEPT the script that is issuing

Greetings all, On a RedHat System - I am issuing a command from script.sh that will add a file extension to a listing of files in a directory. It works, but I need to script from having an extension added as well. Here is what I have tried to no luck: for file in `ls * | awk ' /\./{print... (6 Replies)
Discussion started by: jeffs42885
6 Replies

2. Shell Programming and Scripting

Remove comments from file with specific file name extensions

Hello Unix board community, I have to program a shell script, but I am a complete noob so I hope I get some help here. The assignment is as follows: The program removes all comments regardless of formatting or language from files with specific file name extensions (php, css, js, ...).... (3 Replies)
Discussion started by: TheZeusMan
3 Replies

3. Shell Programming and Scripting

Checking file extensions

I'm in csh and have a list of file names, example set Lst = "file1.ry file2.ry file3.ry file4.ry" I want to check if all the extensions are ry. Is they are, I want to do something. (1 Reply)
Discussion started by: kristinu
1 Replies

4. Shell Programming and Scripting

Checking file extensions

I am trying to store file with certain file extensions to list but having some problems. Here is a part of the code set fryLst = "" set fxtLst = "" foreach f ($AfullNameLst) set fname = $f:r set fext = $f:e if ("$fext" == ".ry") set fryLst = "$fryLst $f" if ("$fext" == ".xt")... (2 Replies)
Discussion started by: kristinu
2 Replies

5. UNIX for Dummies Questions & Answers

Find all the unique file extensions

Hi How can i find the unique list of file extensions in a folder/subfolders e.g. MAIN/ a.txt b.txt a.clas a.java b.class a.txt.112 c.12.ram.jar i just need to get the below out irrespective of file being present in folder or subfolders txt clas java (5 Replies)
Discussion started by: reldb
5 Replies

6. Shell Programming and Scripting

File extensions in a dir

Hi All, Is there a way to list all file extensions in a directory and its recursive dirs? Thanks (5 Replies)
Discussion started by: ganga.dharan
5 Replies

7. Shell Programming and Scripting

Rename files extensions

Hello ! i have a few files like ... setup.001 setup.002 setup.003 setup.004 // to setup.095 and i would like to rename those files to ... setup.r01 setup.r02 setup.r03 setup.r04 // to setup.r95 (7 Replies)
Discussion started by: Putazo
7 Replies

8. Shell Programming and Scripting

Batch changing file extensions

We are moving from an OpenVMS server to a Unix server and I have a problem with ftp'ing files. When I ftp the VMS server from the Unix server, I need to "mget" some files, for example "mget test_file*.txt;". The semicolon is necessary because OpenVMS has multiple versions of the file (eg... (5 Replies)
Discussion started by: cdines
5 Replies

9. Shell Programming and Scripting

Truncate multiple file extensions

Hi, I have files with names like file1.txt.txt.txt.txt and file2.txt.txt.txt.txt.txt............ (random infinite number of .txt exist). how to truncate (mv) their names to ones with single .txt extension like file1.txt and file1.txt ? In other words, how to extract the filename upto first... (12 Replies)
Discussion started by: prvnrk
12 Replies

10. Shell Programming and Scripting

File name extensions

Hello people, I was wondering if anyone could help me? I want to produce a shell script that changes the filename extension on all matching file. E.G. change all files called ‘something.rtf' to ‘something.doc' by giving the command: Changex rtf doc *where ‘Changex' is the name of... (2 Replies)
Discussion started by: thurrock
2 Replies
Login or Register to Ask a Question