The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
mass file mv Sean2008 Shell Programming and Scripting 2 05-14-2008 01:34 AM
Need help with scripting mass file edits.. LinuxRacr Shell Programming and Scripting 16 08-15-2007 08:48 PM
VI questions : mass changes, mass delete and external insert Browser_ice AIX 1 12-13-2006 04:20 AM
mass delete a certain string in a .log file jalge2 UNIX for Dummies Questions & Answers 4 07-27-2005 10:25 AM
Renaming a file name dbrundrett Shell Programming and Scripting 2 01-06-2004 10:36 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-29-2006
Indalecio Indalecio is offline
Registered User
  
 

Join Date: Sep 2006
Location: Sweden
Posts: 59
Post Mass file renaming

Hi

Is there any command I could use to rename a bunch of files resident of the same location to their original name plus a fixed text string of my own?

Example:
File1
File2
File3

Output:
File1.txt
File2.txt
File3.txt

This is easy using a "for" loop but what I want is a one-line command. Could you please help me with this one? Cheers.
  #2 (permalink)  
Old 12-29-2006
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
  
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
Code:
$ ls
file1   file2   file3   file4
$ ls file* | xargs -I{}  mv {} {}.txt
$ ls
file1.txt       file2.txt       file3.txt       file4.txt
You may need -i (lower case 'i') with your version of xargs.

Cheers
ZB
  #3 (permalink)  
Old 12-29-2006
kapilraj kapilraj is offline
Registered User
  
 

Join Date: Dec 2006
Location: Maryland
Posts: 162
ls -1 | awk '{print "mv",$1,$1".txt"}' | ksh
  #4 (permalink)  
Old 12-29-2006
DeepakS's Avatar
DeepakS DeepakS is offline
Registered User
  
 

Join Date: Aug 2006
Posts: 74
Code:
ls -1 --color=none | awk -F "." '{print "mv","\""$1"\"","\""$1".txt\""}' | bash
Using this will tackle spaces in the filename.
  #5 (permalink)  
Old 12-29-2006
kbrede kbrede is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 21
If you have perl installed, look for rename or prename on your system. Use the "-n" switch to test, and then "-v" when you want to make the change.

$ rename -n 's/(.*)/$1.txt/' *
  #6 (permalink)  
Old 12-30-2006
Terrible
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
i dont know but if you want to be very lazy and have your work done for you u can check this site out www.unixfarmland.com i believe theres a couple of programs there that can do ya job for ya
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:06 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0