LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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-18-2007, 08:34 AM   #1
scribbl35
LQ Newbie
 
Registered: Jul 2007
Posts: 1

Rep: Reputation: 0
Script to Move and rename files


Hi there I am new to this and would like to know how to mv and rename a group of files to another directory. I would like to read characters from file then use a string from within the file to rename the file.
 
Old 07-18-2007, 09:14 AM   #2
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
You should be more specific. Something like

Code:
for f in *; do
  mv $f /path/to/$(grep NAME $f)
done
would be along the lines of what you want but almost certainly wouldn't get it as is. If you had a couple of files in the current directory called 'foo' and 'bar' and the contents of foo were

hello
123

and bar was

goodbye
789

and you grepped for '[0-9]' it would move them to /path/to/123 and /path/to/789.
 
  


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
Batch Script to rename files... jamie_barrow Linux - Newbie 16 06-14-2009 01:26 PM
Rename files with script sharathkv25 Programming 14 06-25-2007 03:00 AM
Script to rename files nazs Programming 15 03-31-2007 02:12 PM
Script to Rename Many Files geeman2.0 Programming 3 04-05-2006 01:45 PM
Need script to rename files joe_stevensen Programming 5 12-05-2003 06:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:58 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
Open Source Consulting | Domain Registration