INSERT directory paths into MySQL table

Discussion in 'Software' started by Mada_Milty, Mar 29, 2010.

  1. Mada_Milty

    Mada_Milty MajorGeek

    Good Day,

    I have a directory of files on my webserver, who's paths I would like to upload into a column of a MySQL table.

    I'm thinking I'll have to write a PHP script to do this, but being the lazy guy I am, I am curious if anyone else has a better way. Any input?

    Thanks in advance,

    Milty
     
  2. Mada_Milty

    Mada_Milty MajorGeek

    I've got it! (With some help :))

    What I did was get a directory listing in a text file using DOS commands:

    Code:
    [B]dir[/B] <[I]directoryname[/I]> /s /b >> c:\directorylisting.txt
    And once there, I used a SQL command to upload the list into my table:

    Code:
    LOAD DATA INFILE 'c:/directorylisting.txt' INTO TABLE <[I]tablename[/I]> (<[I]columnname[/I]>);
    This has put a list of 2,780 file paths into my SQL table in a matter of microseconds! SO RAD! http://forums.majorgeeks.com/images/icons/icon14.gif
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds