If there is a directory with the same name as the directory I want to create using python's ftp,
A program created after being deleted.

I want to delete a server-side directory with a windows command using ftp.sendcmd.

Error message

File "test.py", line 45, in ftp_upload
ftp.sendcmd (cmd)

ftplib.error_perm: 500 'rd/s/q D: \ **** \ ******': command not understood.

Applicable source code


cmd = "rd/s/q D: \ **** \ ******"
ftp.sendcmd (cmd)

I tried changing the contents of

cmd, but it didn't work.

Supplemental information (FW/tool version etc.)

Please provide more detailed information here.

  • Answer # 1

    You can only delete a directory in an empty directory
    After deleting all the files in the directory, you need to delete the directory.

  • Answer # 2

    Here is the answer code