相机挑选JPG照片,同步删除RAW格式文件,批处理文件bat,放到JPG和NEF文件夹根目录
– NEF 文件夹
– JPG 文件夹
文件同步删除.bat
@echo off:: 要同步的文件夹及文件后缀名(相同),即要删除文件的目录
set del_subfix=NEF
:: 要参考的文件夹及文件后缀名(相同),即参考的文件的目录
set ref_subfix=JPGset del_dir=.\%del_subfix%\*.%del_subfix%
set ref_dir=.\%ref_subfix%\*.%ref_subfix%echo.
echo * 确保文件 %ref_subfix% 及 %del_subfix% 文件夹在当前程序目录中,且其文件夹名称与其内部的文件后缀相同且大小写一样。
echo * 以 %ref_subfix% 目录中文件为基准,删除 %del_subfix% 目录中多余的 %del_subfix% 格式文件
echo.
setlocal enabledelayedexpansion
set ref_array_index=0
for /f "delims=" %%m in ('dir /a-d /b %ref_dir%') do (set ref_array[!ref_array_index!]=%%~nmset /a ref_array_index=!ref_array_index!+1
)
echo * %ref_subfix% 文件夹中共有!ref_array_index!个 %ref_subfix% 文件
set del_array_index=0
for /f "delims=" %%m in ('dir /a-d /b %del_dir%') do (set del_array[!del_array_index!]=%%~nmset /a del_array_index=!del_array_index!+1
)
echo * %del_subfix% 文件夹中共有 !del_array_index! 个 %del_subfix% 文件
echo.
echo.
echo * 继续分析查找要删除的文件请输入 1 ,取消输入 0 或其他字符
set /p input_confirm=
echo.
if %input_confirm% neq 1 (echo * 已取消!goto EndTip
)
echo 正在分析对比找出要删除的文件:
set del_index=0
set count=0
:BeginLoop2if !del_index! geq !del_array_index! ( goto EndLoop2)set tempDelFile=!del_array[%del_index%]!set /a del_index=!del_index!+1set index_ref=0set flag=0;:BeginLoopif %index_ref% geq !ref_array_index! ( goto EndLoop)set tempRefFile=!ref_array[%index_ref%]!if !tempDelFile! equ !tempRefFile! (set flag=1echo 已查找到名称是!tempDelFile!.%ref_subfix%的文件...进度!del_index!/!del_array_index!goto EndLoop) else (set flag=0)set /a index_ref=%index_ref%+1goto BeginLoop:EndLoopif !flag! == 0 (echo 未查找到名称是!tempDelFile!.%ref_subfix%的文件...进度!del_index!/!del_array_index!set final_array[!count!]=!tempDelFile!.!del_subfix!set /a count=!count!+1)goto BeginLoop2
:EndLoop2
echo.
echo.
if !count! == 0 (echo * 没有任何 %del_subfix% 文件需要删除goto EndTip
)
echo * 共需删除 !count! 个 %del_subfix% 文件,文件列表如下:
set index_tip=0
:BeginLoop1if %index_tip% geq !count! (goto EndLoop1)echo !final_array[%index_tip%]!set /a index_tip=!index_tip!+1goto BeginLoop1
:EndLoop1
echo.
echo.
echo * 确认删除请输入 1 ,取消输入 0 或其他字符
set /p input_source=
echo.
if %input_source% neq 1 (echo * 已取消!goto EndTip
)
set index_final=0
echo ========开始删除=========
echo.
:BeginLoop3if %index_final% geq !count! (goto EndLoop3)del /f /s /q .\%del_subfix%\"!final_array[%index_final%]!"set /a index_final=%index_final%+1set /a progress=%index_final%*100/!count!echo 进度:%index_final%/!count!(!progress!%)goto BeginLoop3
:EndLoop3
echo.
echo ========删除结束=========
echo.
echo.
echo * 文件同步删除完成,共删除 !index_final! 个 %del_subfix% 文件!
:EndTip
echo.
echo. & pause