本帖最后由 ygqiang 于 2014-11-1 01:17 编辑
xx盘DCIM目录下有不同的子目录,里面有很多*.jpg文件,如何全部copy到d盘yy目录下?
只想找到所有jpg文件,全部复制到目标目录下面。- md "d:\%date:~0,4%-%date:~5,2%-%date:~8,2%"
- setlocal enabledelayedexpansion
- for /f %%i in ('dir /b/s e:\*.jpg') do (copy "%%~fi" "d:\%date:~0,4%-%date:~5,2%-%date:~8,2%" /y
- del /q "%%~fi")
- for /f %%i in ('dir /b/s e:\*.mov') do (copy "%%~fi" "d:\%date:~0,4%-%date:~5,2%-%date:~8,2%" /y
- del /q "%%~fi")
- for /f %%i in ('dir /b/s e:\*.avi') do (copy "%%~fi" "d:\%date:~0,4%-%date:~5,2%-%date:~8,2%" /y
- del /q "%%~fi")
- for /f %%i in ('dir /b/s e:\*.mp4') do (copy "%%~fi" "d:\%date:~0,4%-%date:~5,2%-%date:~8,2%" /y
- del /q "%%~fi")
- for /f %%i in ('dir /b/s e:\*.mts') do (copy "%%~fi" "d:\%date:~0,4%-%date:~5,2%-%date:~8,2%" /-y
- del /q "%%~fi")
- pause
复制代码 以上代码运行正常。- for %%a in (e f g h i j k l m n o p q r s t) do (
-
- if exist "%%a:\DCIM" (md "d:\%date:~0,4%-%date:~5,2%-%date:~8,2%"
- setlocal enabledelayedexpansion
- for /f %%i in ('dir /b/s %%a:\*.jpg') do (copy "%%~fi" "d:\%date:~0,4%-%date:~5,2%-%date:~8,2%" /y
- del /q "%%~fi")
- for /f %%i in ('dir /b/s %%a:\*.mov') do (copy "%%~fi" "d:\%date:~0,4%-%date:~5,2%-%date:~8,2%" /y
- del /q "%%~fi")
- for /f %%i in ('dir /b/s %%a:\*.avi') do (copy "%%~fi" "d:\%date:~0,4%-%date:~5,2%-%date:~8,2%" /y
- del /q "%%~fi")
- for /f %%i in ('dir /b/s %%a:\*.mp4') do (copy "%%~fi" "d:\%date:~0,4%-%date:~5,2%-%date:~8,2%" /y
- del /q "%%~fi")
- for /f %%i in ('dir /b/s %%a:\*.mts') do (copy "%%~fi" "d:\%date:~0,4%-%date:~5,2%-%date:~8,2%" /-y
- del /q "%%~fi")
-
- )
- )
复制代码 更新下:这个代码,修改以后,可以正常运行了。 |