From bab350e8dd034b54e3b0bb2e333d2e6e253be70e Mon Sep 17 00:00:00 2001 From: ninjadogz Date: Fri, 25 Oct 2019 00:02:18 +0900 Subject: [PATCH] Create moveVideos.ps1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 文件移动 --- moveVideos.ps1 | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 moveVideos.ps1 diff --git a/moveVideos.ps1 b/moveVideos.ps1 new file mode 100644 index 0000000..ec22917 --- /dev/null +++ b/moveVideos.ps1 @@ -0,0 +1,29 @@ +# The video format you want to move. +$videoFormatLists=("mp4","wmv") +# Source video directory +$fromDir="X:\av" +# Target video directory(path to AVData) +$toDir="X:\AVData" + +function moveVideos ($fromDir, $toDir,$videoFormat) { + $list=@(Get-ChildItem -Path $fromDir -Recurse -File -Include "*.$videoFormat" | ForEach-Object {$_.FullName}) + $list.Length + + # Only one video to move. + if ($list.Length -eq 1) { + Move-Item $list.Replace("`[","``[").Replace("`]","``]") $toDir + # More than one videos to move. + } else { + for($idx=0; $idx -lt $list.Length; $idx++) { + echo "Move file $list[$idx].Replace("`[","``[").Replace("`]","``]") to $toDir" + # escapse [ ] + Move-Item $list[$idx].Replace("`[","``[").Replace("`]","``]") $toDir + } + } +} + +# Move videos +for($idy=0; $idy -lt $videoFormatLists.Length; $idy++) { + moveVideos $fromDir $toDir $videoFormatLists[$idy] +} +