Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 07-18-2007, 08:34 AM   #1
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
Senior Member
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

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

for f in *; do
  mv $f /path/to/$(grep NAME $f)
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


and bar was


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


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
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 > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:48 AM.

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