LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 07-08-2010, 12:55 PM   #1
struct
Member
 
Registered: Feb 2009
Posts: 68

Rep: Reputation: 10
Help: how to rename files based on database entry?


Hi guys, I was hoping to get some pointers on how to rename files based on database entry.
I got hundreds of thousands of files that has GUID name assigned to it. only way to find out the file name is to look up the database table. Its obvious that this is not efficient.
I couldn't find any tutorials on how to do this. Please point me to right direction. A starting point would be very helpful. Thanks in advance.

Last edited by struct; 07-08-2010 at 01:34 PM.
 
Old 07-08-2010, 10:19 PM   #2
joec@home
Member
 
Registered: Sep 2009
Location: Houston Tx
Posts: 89

Rep: Reputation: 29
To get you pointed into the right direction you are going to need the command "mysql -e" to build the script from. As an example, I have system monitoring scripts where I need MySQL information from bash so it can be mixed with other commands to pull system information.

Tiny Example

Code:
echo "What is the MySQL root password?";\
read MYSQLPASS;\
iostat ;\
mysql -uroot -p$MYSQLPASS -e 'SHOW PROCESSLIST;' ;\
ipcs -c
So in theory you should be able to output the information to bash for further processing.

Code:
echo "What is the MySQL root password?";\
read MYSQLPASS;\
for i in $(mysql -uroot -p$MYSQLPASS -e 'SELECT * FROM database_name.table_name.row_name;) ;\
do touch $i ;\
done
 
  


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
bash-code to rename files based on config file Yalla-One Programming 20 04-14-2010 02:39 PM
Bash script rename files based on directory name cupofnestor Linux - General 7 03-31-2010 09:20 AM
Rename database myfoot Linux - Newbie 3 08-30-2008 07:59 AM
Windows Domain Rename and Noticed Odd Log Entry thekillerbean General 3 03-01-2007 02:09 AM
Rename mysql database pk21 Linux - Newbie 4 06-11-2004 06:54 AM


All times are GMT -5. The time now is 03:28 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration