Move-Item
mv で移動できなかった File を確認すると、以下の様になった。
wildcard | reserved characters を filename から排除する必要があるということ。
Move-Item -LiteralPath の利用により、[] が含まれる Filename も移動できる。
全角は止したほうがいい。
“”U+201C|U+201D
- []が含まれている場合、Error 出力なし、そのまま元の場所に残されており、消えたりはしていない。
- ""が含まれている場合、Error 出力あり気付くことができる。こちらも消えたりはしていない。
wildcard | reserved characters を filename から排除する必要があるということ。
Move-Item -LiteralPath の利用により、[] が含まれる Filename も移動できる。
全角は止したほうがいい。
“”U+201C|U+201D
About Filename
操作の都合から、Command で扱うことのできる運用として、以下の様に定めることとする。
移動先に同名が存在する場合、以下のErrorが出力される。この状態での-WhatIfは無意味。
move : Cannot create a file when that file already exists.
+ CategoryInfo : WriteError: (C:\test.txt:FileInfo) [Move-Item], IOException
+ FullyQualifiedErrorId : MoveFileInfoItemIOError,Microsoft.PowerShell.Commands.MoveItemCommand
- 操作の際には、必ず -Literal (文字通り) optionを利用し、Single quote 括り とする。
- left and right bracket や space の利用を制限しない。
移動先に同名が存在する場合、以下のErrorが出力される。この状態での-WhatIfは無意味。
move : Cannot create a file when that file already exists.
+ CategoryInfo : WriteError: (C:\test.txt:FileInfo) [Move-Item], IOException
+ FullyQualifiedErrorId : MoveFileInfoItemIOError,Microsoft.PowerShell.Commands.MoveItemCommand
What if: Performing the operation "Move File" on target "Item: C:\test.txt Destination: D:\test.txt".