We have two custom indices being calculated by S&P. S&P uploads 8 files (4 for each index) to an FTP server folder that I can access. They are uploaded every evening, and I then retrieve them the following morning. I want this to be automated because they only maintain 5 days on the server at a time.
Here are example file names:
20160805_LUKDGUP
20160805_LUKDGUP_NCS
20160805_LUKDGUP_NCS_ADJ
20160805_LUKDGUP_NCS_CLS
20160805_LUKSGUP
20160805_LUKSGUP_NCS
20160805_LUKSGUP_NCS_ADJ
20160805_LUKSGUP_NCS_CLS
What I am trying to do is download them to our local server, have them automatically put into folders based on file name → 20160805_LUKDGUP_* files go into a folder LUKDGUP\20160805\ and the same for LUKSGUP files.
I've tried modifying some batch files from other posts, but think I keep making small mistakes that prevent them from working.
Edit 20160809-0841: I have been trying to modify this to suit my needs, but haven't been able to follow the loop that well:
setlocal
set "basename=."
PAUSE
for /F "tokens=1 delims=_" %%a in ('dir /B /A-D') do (
set "filename=%%a"
setlocal EnableDelayedExpansion
for /F "delims=" %%c in ("!basename!") do if "!filename:%%c=!" equ "!filename!" (
set "basename=!filename!"
md "!basename!"
)
move "!filename!.%%b" "!basename!"
for /F "delims=" %%c in ("!basename!") do (
endlocal
set "basename=%%c
PAUSE
)
)
Source. Of course this doesn't involve the FTP automation, but I figure I can get that part figured out with Filezilla or some other FTP software. Organizing once it's on our server is what this piece was trying to solve.