我試圖找到很多方法來完成這個但仍然沒有希望(嘗試使用陣列等......)
有沒有辦法可以選擇目錄中列出的檔案的一部分并將其輸出如下
例如,如果我輸入 0-2,它會輸出為
00000\.MTS 00001.MTS 00002.MTS
同樣,如果我輸入 3-5,
00003\.MTS 00004.MTS 00005.MTS
示例檔案夾串列
2022-03-24 00:14 \<DIR\> .
2022-03-24 00:14 \<DIR\> ..
2022-03-23 15:47 5,025,792 00000.MTS
2022-03-23 15:47 4,958,208 00001.MTS
2022-03-23 15:47 3,938,304 00002.MTS
2022-03-23 15:47 9,185,280 00003.MTS
2022-03-23 15:48 9,179,136 00004.MTS
2022-03-23 15:48 3,028,992 00005.MTS
我嘗試這樣做的原因是因為我想加入 MTS 檔案,而無需在命令中一一輸入。原來的命令就像
copy /b 00000.MTS 00001.MTS 00002.MTS 00003.MTS 00004.MTS 00005.MTS "C:\\Users\\Desktop\\1.MTS"
希望我可以使用批處理命令
1st : 0-2
copy /b 00000.MTS 00001.MTS 00002.MTS "C:\\Users\\Desktop\\1.MTS"
第二:3-5
copy /b 00003.MTS 00004.MTS 00005.MTS "C:\\Users\\Desktop\\2.MTS"
是否可以在 bat 中完成此操作?
我確實嘗試使用 for 回圈來生成檔案串列,
setlocal enabledelayedexpansion
set /P "mts1=MTS SET 1 : "
for %%n in (%mts1%) do (
echo !FILE_LIST\[%%n\]!
)
但似乎它只顯示所有檔案,而且每個檔案都使用一個新行,不能用于復制 /b
uj5u.com熱心網友回復:
@ECHO Off
SETLOCAL ENABLEDELAYEDEXPANSION
rem The following settings for the source directory and destination directory are names
rem that I use for testing and deliberately include names which include spaces to make sure
rem that the process works using such names. These will need to be changed to suit your situation.
SET "sourcedir=u:\your files\t w o"
SET "destdir=%sourcedir%"
:: Do we have 2 arguments?
IF "%~2" equ "" ECHO need 2 arguments&GOTO :eof
:: calculate the destination filename
SET /a destfile=0
:destloop
SET /a destfile =1
IF EXIST "
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/449369.html
下一篇:將串列中的字典轉換為嵌套字典
