LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Help: how to rename files based on database entry? (http://www.linuxquestions.org/questions/programming-9/help-how-to-rename-files-based-on-database-entry-818728/)

struct 07-08-2010 12:55 PM

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.

joec@home 07-08-2010 10:19 PM

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



All times are GMT -5. The time now is 04:53 PM.