You can import all files in a single folder by script.
You can then use a simple script to omit all records without a fk to the parent table and loop through that set parsing the file name to set the foreign key field for the record it needs to be related to.
Import > Folder, referred to by bigtom, while very useful only applies to certain file types. What type of files are you trying to import?
I would be adding various png, jpg and psd files to a photos table associated to my products table. My thought process had the script going:
1. Select folder
2. Loop each photo
3. Parse style code from each photo name
4. Move file into related record
I would do this to multiple files at a time.
Im wondering where would each photo temporarily go while I am looping them through (another table?)?
Would I remove these "temp" files after the import is done?
If they are ending up in a related table and not in the product table, you can go direct to that table and you do not need a temp table.
The key field will just be empty and they will be unattached to a product.
Use the parsing script to get the key or data that gets you to the key. They just use Set Field to set the key in the image file table. Now it is related properly.
Hard to give you detail without knowing the details about the key field and the info in the file name. I would guess you have some sort of SKU in the file name.
You might end up with something like this:
$sku = parsed info
Set Field [ Images::ProductIDfk; ExecuteSQL("SELECT ProductIDpk FROM Products WHERE sku = ?"; ""; ""; $sku)
I finished my solution and would like to share it (giving back to the community).
What would be the best practice to do so without sharing my entire database?
Just attach the file to a post using the advanced post editor.