I’m trying to make something like this:
(NULL, ‘SeaBattle’, ‘gameboy’, ‘Gameboy’, ‘22′, ‘TheSmartass’, ‘37′, ‘Unsorted’, ‘13′, ‘1′, ‘0′, ‘480′, ‘432′, ”, ‘2009-03-29 19:30:38′, ‘English’, ”, ”, ‘Sea Battle’), all the file names are like SeaBattle in the directory. Can something generate this statement for me inserting all the file names?
Somebody made me a pretty slick perl script, but I like your on the fly way to do it too..
This is how I would do it (just tested that manner; works well):
(on WinXP)
Run cmd to get in console
Get in your directory using cd
Use the following command to get the content of the current directory listed in a file (list.txt):
ls –width=1 > ../list.txt
Now you have a file with the list of files in your directory. Open that file, copy the whole content.
Open a spreadsheet (I use OpenOffice Calc) and paste on the 15th column or so.
Then I fill the table with all needed information (all the other fields in your database).
Then you only have to add SQL syntax elements between the columns, like "INSERT INTO table VALUES(" in the first column (insert a column there if it’s already used), then you add columns between other values "," "’,'" etc depending on if there’s a text field at the left or right. I hope you get the idea; you just have to set the cells as holding text values and you put for example "’," in the first row, then you drag the row till the end of the table, for the total number of entries.
Then you save the file in CSV, specifying to do not separate values with any character. And there you go. That’s how I usually do when I have some hundreds or thousands of tuples to insert at the same time.
Hope this helps!
Good luck!