BATCH Delete subfile/folder in a directory
Cadapen67
-
barnabe0057 Posted messages 14431 Registration date Status Contributeur Last intervention -
barnabe0057 Posted messages 14431 Registration date Status Contributeur Last intervention -
Hello,
I would like to create a script that can delete specific subfiles and folders in multiple directories.
Do you have an example of a script or command lines, please?
Thank you!
Configuration: Windows / Firefox 50.0
I would like to create a script that can delete specific subfiles and folders in multiple directories.
Do you have an example of a script or command lines, please?
Thank you!
Configuration: Windows / Firefox 50.0
3 réponses
Hello,
To delete a folder and everything it contains:
To delete specific folders within multiple folders, you need to provide more details.
I assume this is related to the logs of your FTP server.
To delete a folder and everything it contains:
rmdir /s /q "folder to delete"
To delete specific folders within multiple folders, you need to provide more details.
I assume this is related to the logs of your FTP server.
In fact, I would like to delete specific files, for example:
Delete all files containing "Sample" in their name.
Several of these files exist in different folders within the directory.
Do you have any idea?
Delete all files containing "Sample" in their name.
Several of these files exist in different folders within the directory.
Do you have any idea?
@echo off
set source="the directory of your choice"
cd %USERPROFILE%
for /f "tokens=*" %%A In ('dir /a-d /b /s %source%\*.* ^| find /i "Sample"') do (del /f "%%A" && echo %%~sA = deletion OK && echo.)
pause
This code searches for "Sample" recursively and deletes the corresponding files.
You must replace the underlined part with the directory of your choice.