Modifying an FTP script not to delete files in the LOCAL folder

I would like to modify this portion of an FTP script so that it does try to look at the LOCAL folder to compare files with the REMOTE folder - and then try to delete those files on the REMOTE FOLDER.
I simply want the script to download the files found in the REMOTE folder to the LOCAL folder, Delete the files in the Remote folder - but not to delete anything in the LOCAL folder..


:GetFTPFiles
    (echo open %ftpserver%
    echo user %username% %password%
    echo bin
    echo cd %remotedir%
    echo lcd "%localdir%"
    echo mget *.*
    echo quit
    ) | ftp -n -i
    exit /b

:ClearfTPFiles
    (echo open %ftpserver%
    echo user %username% %password%
    echo cd %remotedir%
    (for /f "tokens=*" %%a in ('dir /b /a-d "%localdir%\*.*"') do @echo dele "%%~a")
    echo quit
    ) | ftp -n -i -d
100questionsAsked:
Who is Participating?
 
Bill PrewCommented:
I would like to modify this portion of an FTP script so that it does try to look at the LOCAL folder to compare files with the REMOTE folder - and then try to delete those files on the REMOTE FOLDER.

Did you really mean does not here?

If so then you could just do this:

:GetFTPFiles
    (echo open %ftpserver%
    echo user %username% %password%
    echo bin
    echo cd %remotedir%
    echo lcd "%localdir%"
    echo mget *.*
    echo mdelete *.*
    echo quit
    ) | ftp -n -i
    exit /b

Open in new window



»bp
0
 
Bill PrewCommented:
All set?


»bp
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.