My suggestion is that you create an ODI procedure using Jython technology to store the file count from your directory in a table in your database. Then use the Refresh Variable tool to retrieve the value from the table using a simple SQL select.
Here's a blog entry I personally refer to time and time again. The example is a little more involved than the scope of your question, but you should be able to get the idea. In particular, review the 'get_file_list' procedure (in section 4) and the 'file_name' variable refresh (section 6).