I am posting this message to you directly, because most of the posts I have read related to my issue you have replied.
I have a process which populates and FTP site randomly thru out the day. I have the following Batch process which goes out to the FTP site and copies the files local, then renames them to an archive folder, then copies the original file to a different FTP folder, and then deletes the original file off the first FTP. The batch file to copy and rename runs on a task schedule ever 15 minutes. The problem I am having is that sometimes a new file will be placed on first FTP after the process starts, and then it gets deleted and not copied.
I have seen several posts about loops, and possibly comparing files from one directory to another before doing my delete but I dont know who to write a batch loop?
Here is my current Batch:
FTP/Copy/Rename/Del Batch loop
I have a batch process which goes to a FTP site and moves all the files to a local directory, then it renames the files and copies those to an archive, then it FTP those files to another FTP site. The last part of the process then DEL the files from the original FTP site.
The problem I am having is, the DEL process deletes new files that have not been copied to FTP directory because they were just added after batch process had begun.
I thought I could loop thru each file one at a time, do the mget/copy/mput/rename/del on one file at a time, which would prevent from deleting new files? Have not found a way to create this type of loop. Also, I dont have exact files names and have to use *.txt, *.set, and *.cse.
Here is the current Batch:
ftp -s:D:\Red\ftpgetsetfiles.txt xxx.xxx.xxx.xxx
COPY "D:\Red\SET\*.set" "D:\Red\SETArchiveRename"
ftp -s:D:\Red\ftpputsetfiles.txt xxx.xxx.xxx.xxx
FOR /f "tokens=1-5 delims=/ " %%d in ("%date%") do rename "D:\Red\SETArchiveRename\*all.set" *all_%%e-%%f-%%g.set
COPY "D:\Red\SETArchiveRename\*.set" "D:\Red\SETArchive"
ECHO Y | DEL D:\Red\SETArchiveRename\*.set
ECHO Y | DEL D:\Red\SET\*.set
ftp -s:D:\Red\ftpdelsetfiles.txt xxx.xxx.xxx.xxx