How delete all Files under a folder using Kudu Console

Nita 1 Reputation point
2021-12-23T03:44:00.477+00:00

I have a Folder, that need to keep the Folder but delete all the files under it, what comment I can use in Kudu console?

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,936 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. ajkuma 28,036 Reputation points Microsoft Employee Moderator
    2021-12-23T10:20:48.747+00:00

    @Nita , Thanks for the question. Based on my understanding of your scenario, I have shared a few suggestions below.
    If my understanding of the ask is incorrect, please do clarify/ share some more details.

    -If you wish to manually ‘delete’ all the files from the intended folder, you may simply use the UX “Delete” button on the App Service Kudu console. (screenshots below)

    -Or as you would typically delete folder content on-prem (doc) via CMD or PowerShell, clear the content of the intended older (including subfolder, subfiles, except the Folder itself).

    Important: Kindly deleted only unwanted files, as the delete operation once performed would be irreversible.

    CMD/Bash  
    del / PATH_TO_FOLDER\*.*  
    for /d %i in (PATH_TO_FOLDER\*.*) do @rmdir /s "%i"  
    

    -> /S : Delete all files and subfolders in addition to the folder itself.
    -> /Q : Quiet - do not display Y/N confirmation

    Example:
    del /q Test*
    for /d %x in (Test*) do @rd /s /q "%x"

    -Reference: discussion

    160019-image.png
    ====via cmdlet====
    160078-image.png

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.