LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-29-2007, 08:36 AM   #1
balistic
LQ Newbie
 
Registered: Jul 2007
Posts: 9

Rep: Reputation: 0
help renaming files


hey i was hoping someone here could help me. i need to rename all files in a directory that contain a ? symbol to be renamed to add a .txt extension on the end (doesnt have to replace the current one), if anyone can help me by telling me what command to use i would be very happy
 
Old 07-29-2007, 08:44 AM   #2
rtspitz
Member
 
Registered: Jan 2005
Location: germany
Distribution: suse, opensuse, debian, others for testing
Posts: 307

Rep: Reputation: 32
Code:
find ./ -maxdepth 1 -iname "*\?*" -exec rename {} {}.txt {} \;
- maxdepth 1 limits it to the current directory ( = not recursive)
 
Old 07-29-2007, 08:58 AM   #3
balistic
LQ Newbie
 
Registered: Jul 2007
Posts: 9

Original Poster
Rep: Reputation: 0
Code:
find ./ -maxdepth 1 -iname "*\?*" -exec rename {} {}.torrent {} \;
spits out.
find: rename: No such file or directory
find: rename: No such file or directory
find: rename: No such file or directory
find: rename: No such file or directory

rename doesnt work is there a way to do it using the mv command or something?
 
Old 07-29-2007, 08:58 AM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Code:
for name in `ls|grep ?`; do mv $name $name.txt; done
Note that ls|grep ? is enclosed in "back-tics", not single quotes.....
 
Old 07-29-2007, 09:04 AM   #5
balistic
LQ Newbie
 
Registered: Jul 2007
Posts: 9

Original Poster
Rep: Reputation: 0
Works, thanks so much and sorry about the double post before
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 files starwarsfan982 Linux - Software 7 10-30-2006 03:06 PM
renaming files TomalakBORG Linux - Newbie 4 12-24-2005 11:14 AM
Renaming files TomalakBORG Linux - Newbie 2 12-05-2005 05:13 PM
renaming files script. xushi Programming 4 10-10-2004 09:06 AM
Renaming files in one go saurya_s Linux - Software 1 01-12-2004 02:16 PM


All times are GMT -5. The time now is 07:35 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration