0
我正在寫這個批處理腳本,但是如果文件擴展名的所有文件都存在,它就會去查看,即使文件存在。我在這裏先向您的幫助表示感謝!找到具有相同擴展批處理腳本的多個文件
@echo off
if not exist C:\Users\%USERNAME%\Desktop\workBackup (
::creates new folder 'workBackup'
mkdir C:\Users\%USERNAME%\Desktop\workBackup
)
set TIMESTAMP=%DATE:~4,2%%DATE:~7,2%%DATE:~10,4%
if not exist C:\Users\%USERNAME%\Desktop\workBackup\%TIMESTAMP% (
::creates new folder to put work into
mkdir C:\Users\%USERNAME%\Desktop\workBackup\%TIMESTAMP%
)
if not exist C:\Users\%USERNAME%\Desktop\workBackup\%TIMESTAMP%\logs (
::creates logs folder
mkdir C:\Users\%USERNAME%\Desktop\workBackup\%TIMESTAMP%\logs
)
if exist C:\User\%USERNAME%\Documents\workspace\out\log\*.xlsx (
::moves all xlsx files to workBackup folder
move "C:\User\%USERNAME%\Documents\workspace\out\log\"*.xlsx C:\Users\%USERNAME%\Desktop\workBackup\%TIMESTAMP%\
) else (
::exits if file no files are found
echo "Files not found"
exit /b
)
if exist C:\User\%USERNAME%\Documents\workspace\out\log\*.xlsx (
::moves all log files to workBackup folder
move "C:\Users\%USERNAME%\Documents\workspace\out\log\"*.log C:\Users\%USERNAME%\Desktop\workBackup\%TIMESTAMP%\logs
) else (
::exits if file no files are found
echo "Files not found"
exit /b
)
哇部分減少容易出錯冗餘,感謝所有的反饋和幫助。明天當我有我的系統時,我會試試這個! – Glen
剛試過,它仍然無法找到文件。我通過評論移動命令嘗試了兩種類型。任何其他想法? – Glen
有一個錯字(用戶缺少s)另外我在這裏做了一個測試,創建了所有的文件夾和批處理作品。 – LotPings