Automatically loading files and adding into file sets

Permalink
I'd like to automatically get files into the File Manager and added to file sets automatically from a shell script.

I'm using RSYNC in a cron job to get files up to my web server into the .../files/incoming directly. I currently manually add those files (daily) into file sets manually I would prefer doing this manual bit as part of the same shell script that does the RSYNC to get the files to the webserver.

Cheers,
...paul monette...

funkijamr
View Replies:
jordanlev replied on at Permalink Reply
jordanlev
There is no built-in way to do this easily, so it would require some custom coding.

A halfway solution might be to write a script that dumps all of the image files into your site's "files/incoming/" directory (create this directory if it doesn't already exist), then log on and go to the File Manager, click the "More" link next to the upload button, then click the "Add Incoming" tab -- now you can import all of the files in that directory and add them to file sets as needed.

If you want to get crazy and fully automate everything, you should look at the code in concrete/tools/files/importers/incoming.php -- you can probably leverage this code for the adding of files to the site. The see the code in concrete/tools/files/add_to.php for how to add files to filesets.

Once you've got the code that imports all the files in a directory and assigns them to the desired fileset, you can create your own "job" by following these instructions:http://www.concrete5.org/documentation/developers/system/jobs...
Then you can have your cron job run this concrete5 job via the URL that's provided in Dashboard -> System & Maintenance -> Jobs (or if you want your cron job to ONLY run this one custom job and not all of the other site jobs, see the last comment in this thread:http://www.concrete5.org/community/forums/customizing_c5/direct_url... )


Good luck!

-Jordan