FTP with dynamic file names
Hi there. I'm having some trouble getting my thoughts together on how to script FTP from an email server to my local directory. Let me first describe the actions that need to be taken by the script (or me, if i'm doing this manually through the WinSCP GUI).
1. Previous BUSINESS day. Downloading from the day before won't work here, or automatically finding the date by subtracting 1 won't work. because I have to account for weekends. This comes in when I have to make the new directory within the 'month' directory and also when I rename the excel files. I cannot make the code I have right now work because I have no idea how to specify where it both takes files and puts them into folders with this business day format.
2. Is this just... too much? Is this too sophisticated for a script? I have no idea how I would write in the script to save the xml file to the directory but make a copy saved as a different file type and renamed.
I have a bit of a script in progress, but like I said, it can't find the directories for the previous business day. I have looked at the timestamp documentation but I don't think that will work for me because there are specific formats for the date that I have no control over and I need to pull these files from business days only...
Please let me know if you have any ideas or if posting my current script would be helpful.
thanks!
I am having some issues with scripting this. I will list them out:open winscp. connect to remote server and log in with pass phrase. on the local side, create a folder within a 'month' folder titled with the PREVIOUS BUSINESS DAY in YYYYMMDD format. transfer zipped file from the remote side to the local side. keep the zipped folder inside the folder for the previous day, but take out the single xml file inside. keep this file, but open it in word and save a copy as an excel document. this should leave you with 3 files in the new date-from-previous-business-day-folder: the original zip folder transferred from the remote server, the XML document that was inside, and a copy of the XML document saved as an excel spreadsheet. rename the EXCEL file inside to something new (some pretext from the original file name and the YYYYMMDD value, i.e. TTR_168 20220726). this should be done for 8 files from the remote server.
1. Previous BUSINESS day. Downloading from the day before won't work here, or automatically finding the date by subtracting 1 won't work. because I have to account for weekends. This comes in when I have to make the new directory within the 'month' directory and also when I rename the excel files. I cannot make the code I have right now work because I have no idea how to specify where it both takes files and puts them into folders with this business day format.
2. Is this just... too much? Is this too sophisticated for a script? I have no idea how I would write in the script to save the xml file to the directory but make a copy saved as a different file type and renamed.
I have a bit of a script in progress, but like I said, it can't find the directories for the previous business day. I have looked at the timestamp documentation but I don't think that will work for me because there are specific formats for the date that I have no control over and I need to pull these files from business days only...
Please let me know if you have any ideas or if posting my current script would be helpful.
thanks!