如何进行文件名搜索,删除该名称下的所有文件,



我想进行文件名搜索,删除该名称下的所有文件。

我想它在里面说你今天想搜索什么文件,我键入一个示例eminem,它会有一个列表,上面写着找到了320个文件名为eminem的文件,它会列出文件类型,例如20.img文件名为eminem 300.mp3文件名为emnem,然后有一个选项说你想删除这些文件吗。

另一个想法是选择在哪里搜索一个示例记忆棒,您可以使用它来搜索和删除所有文件。这只是一个想法,我认为这将非常有用,我已经找到了一些可以搜索文件的代码。

我想很好地说,你想搜索什么,让你输入你想搜索的内容,它会搜索它,你可以选择删除它们,我觉得这很有用。

这是我已经的一些代码

@echo off
DIR /s c:eminem - superman.mp3
::and to delete it the code would be 
del /p /s c:minecraft.exe

但我的想法是使用批处理来创建一个文件搜索删除工具。

你可以尝试这样的东西:

@echo off
Title Searching by file name and delete it
Color 9E & Mode con cols=60 lines=3
echo(
set /P "file=Type the name of file to search : "
cls
Color 9D & Mode con cols=100 lines=100
echo(
echo                   Please Wait ... Searching for "%file%" is in progress ....
setlocal EnableDelayedExpansion
rem Populate the array with existent files in folder
set i=0
for /f "delims=" %%a in ('dir "C:%file%*.*" /s /b') do (
   set /A i+=1
   set "list[!i!]=%%a"
)
set Files=%i%
rem Display array elements
cls
for /L %%i in (1,1,%Files%) do (
    echo(
    echo file number %%i: "!list[%%i]!" 
    echo(
)
pause
echo.
Set /P "nbFile=Type the file number in the list above to delete or Type ALL to delete all files = "
If /I "%nbFile%" == "ALL" (
    for /L %%i in (1,1,%Files%) do (
        echo Del "!list[%%i]!"
        pause
        Del "!list[%%i]!"
    )
) Else (    
    for /L %%i in (1,1,%Files%) do (
        IF "%nbFile%" equ "%%i" (
            echo Del "!list[%nbFile%]!"
            pause
            Del "!list[%nbFile%]!"
        )   
    )   
)   
pause
exit

最新更新