BAT extracts files of specified types in the current directory and subfolders with one click

This is a Windows batch script that extracts files of a specified type under the current directory and its subfolders and copies them to a folder named "Extraction Results_File Types".

The script first asks you to enter the file type you want to extract, such as MP4, JPG, etc. It will then create a new folder (if it does not exist) to store the extracted result files.

Next, the script searches the current directory and its subfolders for files of the specified type and copies them to the extraction results folder while preserving the original filename and extension. Once completed, the script prompts you to press any key to continue entering other file types for further extraction operations.

 Type notepad with Windows+R on the computer and press Enter to copy the following script into the text, then save it as a folder in the folder that the user wants to traverse, name it as a file ending in .bat or .cmd and save it. Double click to start and use

Extract files of specified types in the current directory and subfolders with one click

@echo off &title 一键提取当前目录及子文件夹下指定类型的文件  ~by 阿牛 &chcp 936 &color a

echo ╲╱将当前目录及子文件夹下指定类型的文件提取到当前目录下的“提取结果_文件类型”文件夹中╱╲

:inputFileType
REM 请求用户输入要提取的文件类型 ╲╱╱╲╲╱╱╲╲╱╱╲╲╱╱╲╲╱╱╲╲╱╱╲╲╱╱╲╲╱╱╲╲╱╱╲╲╱╱╲╲╱╱╲
echo.
set /p fileType= ^^_^^ 请输入要提取的文件类型后回車(如 MP4、JPG 等):
set "fileType=%fileType%"
set "uppercaseFileType=%fileType:~0,1%%fileType:~1%"
set "uppercaseFileType=%uppercaseFileType:uCase=%"

REM 创建新的提取结果文件夹(如果不存在)
if not exist 提取结果_%uppercaseFileType% (
echo.&echo 创建“提取结果_%uppercaseFileType%文件夹
mkdir 提取结果_%uppercaseFileType%
)
echo
echo.===================================
echo 3秒后开始提取 %fileType% 文件,请稍后。。。
echo 待提取完成后将弹出 提取结果_%fileType%
echo.=================================== &timeout>nul /t 2

for /r %%i in (*.%fileType%) do (
echo 复制 "%%i" 到 提取结果_%uppercaseFileType%\%%~nxi
copy "%%i" 提取结果_%uppercaseFileType% > nul
)
explorer 提取结果_%uppercaseFileType%
echo.&echo 完成 "%uppercaseFileType%" 格式文件的提取。3秒后继续输入其他格式类型。 &timeout>nul /t 2 
REM pause > nul

goto inputFileType

—————————————————————————————— Complete 

Guess you like

Origin blog.csdn.net/awzs7758520/article/details/131559160