我正在使用ERP Bext,Bext生成需要的.txt和.top文件。 脚本的目标是在存档文件夹中移动名称相同但扩展名不同的文件
这是我的脚本:
@echo off
title Script-Tri-Bext
ping localhost -n 2 > nul
cd "C:\Users\ngallouj\Desktop\bex"
IF NOT EXIST "C:\Users\ngallouj\Desktop\bex\archive" mkdir archive
::alt va contenir les .top et les .txt non trié
IF NOT EXIST "C:\Users\ngallouj\Desktop\bex\alt" mkdir alt
echo "Configuration : OK"
ping localhost -n 2 > nul
:: Tri des fichiers par paire
for %%i in ("C:\Users\ngallouj\Desktop\bex*.top") do (
if exist "%%.txt" (
echo "Successfully"
move /y "%%~i" "C:\Users\ngallouj\Desktop\bex\archive"
move /y "%%~.top" "C:\Users\ngallouj\Desktop\bex\archive"
)
)
ping localhost -n 2 > nul
::
pause
谢谢:)
答案 0 :(得分:1)
@echo off
title Script-Tri-Bext
ping localhost -n 2 > nul
cd "C:\Users\ngallouj\Desktop\bex"
IF NOT EXIST "C:\Users\ngallouj\Desktop\bex\archive" mkdir archive
::alt va contenir les .top et les .txt non trié
::IF NOT EXIST "C:\Users\ngallouj\Desktop\bex\alt" mkdir alt
@echo off &setlocal
for %%i in ("C:\Users\ngallouj\Desktop\bex\srvbext\*.txt") do (
if exist "%%~dpni.top" (
echo "copie en cours"
move /y "%%~i" "C:\Users\ngallouj\Desktop\bex\archive"
echo "copie 1 fichier"
move /y "%%~dpni.top" "C:\Users\ngallouj\Desktop\bex\archive"
)
)
echo "Copie des fichiers : OK"
ping localhost -n 2 > nul
::
pause
这是解决方法