![](/img/trans.png)
[英]Read the file names of all *.kla files in a directory, rename them and move them to a new directory by batch
[英]Batch file to find .ts files in subfolders, and then move them to a directory?
我找到了可以在子文件夾中找到所有.ts文件的代碼,然后創建它們的日志。 除了創建日志外,我還需要將它們全部移動到目錄中,以便它們可以在一起。 這是我的代碼:
@echo off
setlocal enabledelayedexpansion
set /a counter=1
for /r %%i in (*.ts) do (
echo !counter! %%~nxi >> search_result.txt
set /a counter=!counter!+1
)
endlocal
多謝你們!
插入for
循環的主體
echo(move "%%i" "c:\destination directory\"
(代替您發布的代碼中的空白行)
結果應該是要移動哪些文件的報告。
如果報告正確,請更改echo(move
move
以實際移動文件。
注意echo(
是正確的-在這里實際上不是必需的( echo
滿足),但可以確保如果echo
的參數完全為空,則會生成換行符,而不是echo status report
。
請注意,如果目標目錄中已經存在文件名,那么move
將成為對象,文件名顯然取決於您。
正如他說的“ Magoo”
如果報告正確,請更改
echo(move
move
以實際移動文件。
@echo off
Set NameFolder=TSFolder
Set DestinationFolder=%~dp0%NameFolder%
Set LogFile=search_result.txt
If Not Exist %DestinationFolder% MD %DestinationFolder%
setlocal enabledelayedexpansion
set /a counter=1
(
for /r %%i in (*.ts) do (
echo !counter! - %%~nxi
echo(move "%%i" "%DestinationFolder%"
set /a counter=!counter!+1
)
)> %LogFile%
endlocal
Start "" %LogFile%
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.