LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-09-2007, 09:13 AM   #1
DIMonS
LQ Newbie
 
Registered: Aug 2007
Posts: 13

Rep: Reputation: 0
Question Renaming multipe files without extensions


I am attempting to copy multiple files in multiple directories to another location. Easy.

At the same time I would like to add a .txt extension to the end of every file in every directory but keep the directory names the same. Not so easy. All the commands I have located so far pretty much rely on you wanting rename files.

MMV appears to be the favorite but I cannt seem to get around the recursive issue.

I would forward to hearing from you.

DIMonS
 
Old 08-09-2007, 10:36 AM   #2
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,499
Blog Entries: 2

Rep: Reputation: 68
You want to copy files from one place, recursively, to another location, adding the suffix ".txt" to theses files ?
This is a two steps procedure.
1) copy all the files from one location to another using cp recursive or tar or whatever
2) use find in the new location to rename only the files. Something like that:
Code:
find newlocation -type f -exec mv {} {}.txt \;
 
Old 08-09-2007, 11:15 AM   #3
shadowsnipes
Senior Member
 
Registered: Sep 2005
Distribution: Slackware
Posts: 1,443

Rep: Reputation: 73
Code:
find newlocation -type f -exec /usr/bin/mv '{}' '{}'.txt \;
might be a little safer though the other should still work.
 
Old 08-09-2007, 11:29 AM   #4
elsheikhmh
Member
 
Registered: Aug 2004
Location: Cairo, Egypt
Distribution: Slackware
Posts: 101

Rep: Reputation: 15
yet another alternative
Code:
for i in `find -type f`
do
mv $i $i.txt
done
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
renaming extensions christina_rules Linux - Newbie 6 05-23-2006 09:04 AM
renaming files TomalakBORG Linux - Newbie 4 12-24-2005 10:14 AM
Renaming files TomalakBORG Linux - Newbie 2 12-05-2005 04:13 PM
bash help, renaming file extensions trey85stang Linux - General 8 07-21-2005 04:51 PM
An easy way of deleting lines from multipe files? delawhere Linux - General 2 04-02-2004 11:58 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration