Inserting file details into MySQL in CentOS
Posted on 2013-11-09
I have thousands of files stored in this location in a CentOs server:
All file names are like this:
This file name represents two numbers (123 and 45678) and a full date (2013/11/29) and a time (15:45:30)
I have a MySQL database named (filedb). A table named (files) has the following columns:
id ===== is a sequential number
source ===== is 123
destination ===== is 45678
date ==== is 11/29/2013
time ==== is 15:45:30
file ==== is the file name 123_45678_2013_11_29_15_45_30.gsm
note ==== is an empty field
I need a script which should insert an entry to the (filedb) database for each file in the /var/source/ directory.
Note that the first two sections (123) and (45678) can vary in length. They may be 3,4,5 or more digits. The only wan to recognise sections is by underscores.
I have already setup a username and a password for accessing the MySQL database.
Would any body write the required script for me?
Thanks in advance.