How to import multiple Files

Ok, not being a Unix or PHP guru (yet!) it took me a little while to figure out how to import multiple files into Matrix using the command line. For others about to do same here are the steps:


1)create a folder on your server, "import" for example

2)inside that folder create a folder with the name of the asset ID you would like the files to import to. So for example, if you have a folder in you asset tree with ID 899, name the folder 899

2.5) add the files you wish to import into this 899 directory(in your case, your asset id#)

3) navigate to matrix_install_path/scripts/import/

4)run the php script import_files.php with the following params:

    php import_files.php /pathTomatrix/ /pathtoImportFolder/


for example on my system it's:
    php import_files.php /home/dale/matrix/ /home/dale/import/


5) sit back and watch the fun
6) your files will now be inported under the asset ID you named the folder after

ok, hope that helps someone.

Cheers
Dale

For those twits like me that got sidetracked trying to install the cli version of php - first check that it is not already installed! I did this on RHEL4 with the command

    php-cli -v

If you get a response - you are good to go. Substitute php-cli for php in the example scripts above.

Ok, so you don't need to specify the 899 directory when running the script?

[quote]Ok, so you don’t need to specify the 899 directory when running the script?
[right][post=“10517”]<{POST_SNAPBACK}>[/post][/right][/quote]

Correct, I’ll look in the folder specified and see the 888 sub folder and interpret that as the asset ID to import into

[quote]Correct, I’ll look in the folder specified and see the 888 sub folder and interpret that as the asset ID to import into
[right][post=“10518”]<{POST_SNAPBACK}>[/post][/right][/quote]

Ass long as you have created the parent asset ID folder etc, all will work.



You may also want to check the php script execution.



importing a couple of hundred files took a couple of goes the first time…

[quote]For those twits like me that got sidetracked trying to install the cli version of php - first check that it is not already installed! 
[right][post=“10504”]<{POST_SNAPBACK}>[/post][/right][/quote]



On your server, we installed the Squiz PHP CLI RPM (part of the service). :slight_smile: RHEL4/CentOS does not ship with a php-cli binary by default.

[quote]importing a couple of hundred files took a couple of goes the first time…
[right][post=“10519”]<{POST_SNAPBACK}>[/post][/right][/quote]



Yeah, you may need to set a much higher memory limit, particularly for mass importing PDF or Word documents. Remember, Matrix has to index them all during the import, which requires memory.