PowerShell/ファイル収集コピー
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
''[[TopPage]]''
* ファイル収集スクリプト [#t3e7ade7]
コピー元ディレクトリ配下の全ファイルをコピー先ディレクト...
** 使用方法 [#y16642f4]
PowerShell -F ./fCopy.ps1~
fromDirとtoDirを指定します。~
ポリシーで実行できない場合はpowershell -ExecutionPolicy R...
** 関連ページ [#ib4c903e]
~
ファイル名: fCopy.ps1
[string]$fromDir = "G:\from"
[string]$toDir = "G:\to"
[string]$fName = ""
[string]$ext = ""
[string]$bName = ""
[int]$fCnt = 0
[int]$fSize = 0
Get-ChildItem $fromDir -Recurse -include *.* -Name | For...
$fName = @(Split-Path $_ -Leaf)
if( Test-Path "$($toDir)\$($fName)" ) {
$fSize = (Get-ChildItem "$($fromDir)\$($_)").Length
if( $fSize -eq (Get-ChildItem "$($toDir)\$($fName)")...
echo "同一ファイルのためコピーしません。$($fromDir...
$fName = "dumm565656565"
} else {
$cnt = 0
while( Test-Path "$($toDir)\$($fName)$($cnt.ToStri...
$cnt++
}
$ext = (Get-ChildItem "$($fromDir)\$($_)").Extension
$bName = (Get-ChildItem "$($fromDir)\$($_)").BaseN...
$fName = "$($bName)_$($cnt.ToString("0000"))$($ext)"
}
}
if( $fName -ne "dumm565656565" ){
Copy-Item "$($fromDir)\$($_)" "$($toDir)\$($fName)"
echo "コピーしました。$($fromDir)\$($_) → $($toDir)\...
}
}
*** 参考ページ [#y3729b39]
https://qiita.com/alchemist/items/e6706cd425f8f5e5032e~
終了行:
''[[TopPage]]''
* ファイル収集スクリプト [#t3e7ade7]
コピー元ディレクトリ配下の全ファイルをコピー先ディレクト...
** 使用方法 [#y16642f4]
PowerShell -F ./fCopy.ps1~
fromDirとtoDirを指定します。~
ポリシーで実行できない場合はpowershell -ExecutionPolicy R...
** 関連ページ [#ib4c903e]
~
ファイル名: fCopy.ps1
[string]$fromDir = "G:\from"
[string]$toDir = "G:\to"
[string]$fName = ""
[string]$ext = ""
[string]$bName = ""
[int]$fCnt = 0
[int]$fSize = 0
Get-ChildItem $fromDir -Recurse -include *.* -Name | For...
$fName = @(Split-Path $_ -Leaf)
if( Test-Path "$($toDir)\$($fName)" ) {
$fSize = (Get-ChildItem "$($fromDir)\$($_)").Length
if( $fSize -eq (Get-ChildItem "$($toDir)\$($fName)")...
echo "同一ファイルのためコピーしません。$($fromDir...
$fName = "dumm565656565"
} else {
$cnt = 0
while( Test-Path "$($toDir)\$($fName)$($cnt.ToStri...
$cnt++
}
$ext = (Get-ChildItem "$($fromDir)\$($_)").Extension
$bName = (Get-ChildItem "$($fromDir)\$($_)").BaseN...
$fName = "$($bName)_$($cnt.ToString("0000"))$($ext)"
}
}
if( $fName -ne "dumm565656565" ){
Copy-Item "$($fromDir)\$($_)" "$($toDir)\$($fName)"
echo "コピーしました。$($fromDir)\$($_) → $($toDir)\...
}
}
*** 参考ページ [#y3729b39]
https://qiita.com/alchemist/items/e6706cd425f8f5e5032e~
ページ名: