Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 07-08-2010, 12:55 PM   #1
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
Registered: Sep 2009
Location: Galveston Tx
Posts: 291

Rep: Reputation: 70
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

echo "What is the MySQL root password?";\
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.

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


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 > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:26 PM.

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