You are here:  » FTP delievered file with changing Date in file name?


FTP delievered file with changing Date in file name?

Submitted by BobL on Wed, 2013-11-27 13:50 in

Hi David,
I hope everything is well on your end.

I joined a new network that ftps files daily to our server.
The problem we ran into, is that each day the file names change because of the date stamp in them.

Example:
MyPrograms-20131125.txt
MyPrograms-20131126.txt
MyPrograms-20131127.txt

Is there away to handle this by the automation tool?
To import it from the ftp directory to the feed directory...

Thanks in advance
Bob

Submitted by support on Wed, 2013-11-27 14:50

Hello Bob,

A simple solution would be to add support for a %DATE% placeholder for the URL field of an Automation Tool job, and then set-up jobs for this feed effectively FTP'ing the files from your own server using an appropriate FTP URL.

To do this, edit includes/automation.php and look for the following code at line 21:

    $job = $jobs[0];

...and REPLACE with:

    $job = $jobs[0];
    $job["url"] = str_replace("%DATE%",date("Ymd"),$job["url"]);

Then, create jobs for this and similar feeds using an ftp:// URL pointing to your own server and path to the directory in which the files are pushed to you by the network, e.g.

ftp://username:password@ftp.yoursite.com/incoming/MyPrograms-%DATE%.txt

I would also consider setting up a separate cron job to empty the incoming folder regularly - let me know if you're not sure how to go about setting that up

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by BobL on Wed, 2013-11-27 15:14

Bob L.

As always.... You be the man with the Midas touch.
Works perfectly.
Many thanks.