LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-07-2006, 05:11 PM   #1
amushtaq
LQ Newbie
 
Registered: Sep 2005
Posts: 17

Rep: Reputation: 0
File renaming


i have a repository of files which i want to rename. i have a csv which contains the mappings from the old names to the new names.

e.g:

oldname,newname
123,567
534,127
675,978

is there any utility which would read the mappings from the csv and rename the files accordingly.
 
Old 01-07-2006, 05:59 PM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Maybe something like this....
Code:
#!/bin/bash

cat file.txt |\
while read i ; do
j=`echo "$i" | awk -F, '{print$2}'`
mv `echo "$i" | awk -F, '{print$1}'` "$j"
done
 
Old 01-13-2006, 05:40 AM   #3
amushtaq
LQ Newbie
 
Registered: Sep 2005
Posts: 17

Original Poster
Rep: Reputation: 0
Thanks that was really helpful
 
  


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
bash help, renaming file extensions trey85stang Linux - General 8 07-21-2005 04:51 PM
Complex file renaming Imyrryr Linux - General 3 04-29-2005 08:27 AM
renaming a file?? U-Toast Linux - Newbie 2 08-29-2004 01:07 AM
Bulk File Renaming nevereverend Linux - Newbie 11 07-03-2004 05:28 PM
renaming or converting a text file to a dat file... tangaz Linux - Software 1 10-24-2003 06:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:21 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