文件未复制;也没有把自定义的文件夹和文件移动到指定文件夹
时间: 2023-08-07 22:03:59 浏览: 94
非常抱歉,可能是我之前的代码有问题。以下是修改后的代码:
```batch
@echo off
setlocal enabledelayedexpansion
set "current_path=%cd%"
set "model_folder=%current_path%\程序模型"
set "process_folder=%current_path%\工艺规程"
set "communication_folder=%current_path%\沟通记录"
set "target_folder=%current_path%\工艺文件"
if not exist "%model_folder%" mkdir "%model_folder%"
if not exist "%process_folder%" mkdir "%process_folder%"
if not exist "%communication_folder%" mkdir "%communication_folder%"
if not exist "%target_folder%" mkdir "%target_folder%"
for /d %%f in ("%current_path%\*") do (
set "folder_name=%%~nxf"
if "!folder_name!"=="0000-00-客户沟通" (
call :move_files "%%~f" ".doc" "%communication_folder%"
) else if "!folder_name!"=="0000-01-Rough" (
call :move_files "%%~f" ".prt" "%model_folder%"
) else if "!folder_name!"=="0000-02-Rough_2" (
call :move_files "%%~f" ".prt" "%model_folder%"
) else if "!folder_name!"=="0000-03-Semi-Finish" (
call :move_files "%%~f" ".cxp" "%process_folder%"
) else if "!folder_name!"=="0000-04-Finish" (
call :move_files "%%~f" ".cxp" "%process_folder%"
) else if "!folder_name!"=="工艺模板" (
xcopy /s /y "%%~f" "%target_folder%\工艺模板\" >nul
rd /s /q "%%~f"
) else if "!folder_name!"=="工装" (
xcopy /s /y "%%~f" "%target_folder%\工装\" >nul
rd /s /q "%%~f"
)
)
goto :eof
:move_files
set "folder=%~1"
set "ext=%~2"
set "target_folder=%~3"
for /r "%folder%" %%f in (*) do (
set "file_name=%%~nxf"
set "file_ext=%%~xf"
if "!file_ext!"=="%ext%" (
move "%%~f" "%target_folder%\!file_name!" >nul
)
)
goto :eof
```
请将该代码保存为 `move_files.bat` 文件,与需要进行文件整理的目录放在同一目录下。双击运行 `move_files.bat` 文件即可。
如果还有问题,请随时联系我。
阅读全文