Have batch script as follows:
>>ftp.txt open ftp.site.com
>>ftp.txt username
>>ftp.txt password
>>ftp.txt directoryname
>>ftp.txt quit
ftp -s ftp.txt
How can I delete all files in folder 'directoryname'?
Have batch script as follows:
>>ftp.txt open ftp.site.com
>>ftp.txt username
>>ftp.txt password
>>ftp.txt directoryname
>>ftp.txt quit
ftp -s ftp.txt
How can I delete all files in folder 'directoryname'?
Put the following commands in ftp.txt and run as follows to accomplish this task:
ftp -i -s:ftp.txt
contents of ftp.txt:
open ftp.site.com
username
password
cd directoryname
mdelete *
quit
Here is a complete and safe solution!
One thing is that you have to have a 'y' for every file, and it doesn't matter if you have too many, you can have hundreds it only takes seconds and gives error messages that you'll never are able to see.
The temp file creates in the same folder as your bat file and will be erased by the script.
You can also use mdelete * even if dir * shows all files in the sub-folders.
@echo off
echo.
:MENU
cls
echo.
echo What do you want to do?
echo.
echo 1 - Delete all files in a folder at FTP using ftp batch script
echo 2 - Cancel
echo 3 - Logout
echo.
set /p choice=
if %choice%==1 goto sure
if %choice%==2 goto cancel
if %choice%==3 goto ?
echo Invalid Choice
echo.
pause
goto MENU
:sure
echo.
echo Are you sure to delete all files y/n
echo.
set /p choice=
if %choice%==y goto delete
if %choice%==Y goto delete
if %choice%==n goto cancel
if %choice%==N goto cancel
echo Invalid Choice
echo.
pause
goto sure
:delete
echo open my-domain.com> temp.txt
echo username>> temp.txt
echo password>> temp.txt
echo cd public_html/directoryname>> temp.txt
echo mdelete *.*>> temp.txt
echo y>> temp.txt
echo y>> temp.txt
echo y>> temp.txt
echo y>> temp.txt
echo y>> temp.txt
echo y>> temp.txt
echo y>> temp.txt
echo y>> temp.txt
echo y>> temp.txt
echo y>> temp.txt
echo y>> temp.txt
echo y>> temp.txt
echo y>> temp.txt
echo y>> temp.txt
echo y>> temp.txt
echo y>> temp.txt
echo y>> temp.txt
echo y>> temp.txt
echo y>> temp.txt
echo y>> temp.txt
echo y>> temp.txt
echo y>> temp.txt
echo y>> temp.txt
echo y>> temp.txt
echo y>> temp.txt
echo y>> temp.txt
echo y>> temp.txt
echo y>> temp.txt
echo y>> temp.txt
echo quit>> temp.txt
REM Start FTP and send it to the script
ftp -s:temp.txt
REM delete the temp-file
del temp.txt
cls
echo.
echo All files are deleted!
echo.
pause
goto MENU
:cancel
echo.
echo You have cancelled the erasement!
echo.
Pause
goto MENU