我可以用 cmd 做這個嗎?
例如
c:\a\a1\qw.exe => c:\a1\qw.exe 這樣的
我有很多這樣的目錄,所以我想了解如何在 Windows 中執行此操作?
我想在一個命令中移動多個檔案夾
謝謝您的回答
uj5u.com熱心網友回復:
您可以結合move兩個for /d回圈:
for /d %i in (?) do for /d %j in ("%i\*.*") do move "%j" .
第一個回圈將查找當前目錄下具有單個字符(?將匹配a, b)的所有目錄。第二個回圈將找到這些目錄中的所有目錄(*.*將匹配所有內容)并將其移動到當前目錄。
如果您沒有單字母目錄,請替換?為*.*。但請注意:不要在 中運行它C:\,否則它會嘗試將所有文??件夾移出Windows和Program Files目錄。
uj5u.com熱心網友回復:
移動命令允許用戶將檔案或目錄從一個目錄傳輸到另一個目錄,或從一個驅動器傳輸到另一個。
https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/move
move /?
移動命令示例
要將c:\windows\test 的檔案移動到根目錄下的test 目錄,當然前提是你有Windows\test 目錄。
move c:\windows\test\*.* c:\test
Powershell 移動專案
Move-Item cmdlet 將專案(包括其屬性、內容和子專案)從一個位置移動到另一個位置。這些位置必須由同一提供商支持。例如,它可以將檔案或子目錄從一個目錄移動到另一個目錄,或者將注冊表子項從一個鍵移動到另一個。移動專案時,它會添加到新位置并從其原始位置洗掉。
https://social.technet.microsoft.com/Forums/en-US/729f90e2-4c1d-445d-ad72-6f752a3d7d24/powershell-move-folder-and-subfolders
使用 PowerShell Move-Item 的示例
$parentpath = "C:\Temp"
$files = Get-ChildItem -Path $parentpath -Filter "*.txt" -Recurse
Set-Location $parentpath
New-Item -Name "test" -ItemType Directory -ErrorAction SilentlyContinue
Set-Location .\test
foreach ($file in $files)
{
$destination = New-Item -ItemType directory -Name $(split-path $file.Directory -Leaf) -erroraction 'silentlycontinue'
$file | Move-Item -Destination $destination
}
位傳輸
我的 Bit-Transfer 腳本在這里。我會把它放在這里給你,但有些人開始抱怨我把自己的腳本復制到了這篇文章中。
從本地備份 www 目錄到網路驅動器 powershell
在這里你可以使用 WhatIf -- 'd:\deneme\a\a1', 'd:\deneme\b\b1', 'd:\deneme\c\c1' 'd:\deneme\a1' , 'd:\deneme\b1', 'd:\deneme\c1'
$paths = "d:\deneme\a\a1", "d:\deneme\b\b1", "d:\deneme\c\c1"
ForEach($path in $paths) {
$path = $path.ToString()
$up = $path.Substring(0, $path.lastIndexOf('\'))
#Move-Item -Path $path -Destination $up -force -Verbose
Move-Item -Path $path -Destination $up -WhatIf
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/375533.html
