Skip to content

Instantly share code, notes, and snippets.

@foundkey
Last active December 29, 2018 06:49
Show Gist options
  • Save foundkey/f7345f7e4722c75c7fc321a25d89c005 to your computer and use it in GitHub Desktop.
Save foundkey/f7345f7e4722c75c7fc321a25d89c005 to your computer and use it in GitHub Desktop.
copy special type file to targe folder
::复制指定类型的文件到同一个文件夹
::2018-12-19
::FK
@echo off
setlocal enabledelayedexpansion
set DIR=%~pn1
set /p Type= filter file extension:
set OUTDIR=%~1_%Type%
if NOT EXIST %OUTDIR% (
mkdir %OUTDIR%
)
::拷贝指定类型文件添加随机数后缀,防止重名文件
for /f %%i in ('dir /b /s %1\*.%Type%') do (
copy %%~i %OUTDIR%\%%~ni_!RANDOM!_%%~xi
)
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment