Current location: Hot Scripts Forums » Programming Languages » PHP » How to read folder content file names and export it to mysql


How to read folder content file names and export it to mysql

Reply
  #1 (permalink)  
Old 05-31-08, 10:30 AM
method method is offline
Wannabe Coder
 
Join Date: Jul 2006
Posts: 228
Thanks: 0
Thanked 0 Times in 0 Posts
How to read folder content file names and export it to mysql

Hi all. i have a huge list of vidoes(Mostly avi files). I want some how read the name of all those files and add them to mysql. Could any one show me how i can read all those video file names?Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 05-31-08, 10:40 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,074
Thanks: 11
Thanked 88 Times in 83 Posts
Take a look at glob() to read the files into an array, then use a foreach() loop to loop through the array, and finally run a mysql_query() to add it to your table.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 06-02-08, 09:45 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
This is another option - you might be able to create a CSV listing of your files.

Something like (syntax is rough):

ls avi_dir | sed "s/\r/\,/" > outfile

Then use the LOAD DATA MySQL command

http://dev.mysql.com/doc/refman/5.0/en/load-data.html
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 01:37 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.