Differences
This shows you the differences between the selected revisions of the page.
| library_example_advanced_rename 2023-01-11 | library_example_advanced_rename 2023-01-11 (current) | ||
| Line 24: | Line 24: | ||
| # @version 7 | # @version 7 | ||
| # @homepage ~~SELF~~ | # @homepage ~~SELF~~ | ||
| - | # @require WinSCP 5.16 | + | # @require WinSCP 5.19 |
| # @option - -run group "Rename" | # @option - -run group "Rename" | ||
| # @option Pattern -run textbox "Replace file name part matching this pattern:" | # @option Pattern -run textbox "Replace file name part matching this pattern:" | ||
| Line 132: | Line 132: | ||
| { | { | ||
| Write-Host "$file => $newName" | Write-Host "$file => $newName" | ||
| - | + | ····················$fileMask = [WinSCP.RemotePath]::EscapeFileMask($file) | |
| - | ····················$fullName = [WinSCP.RemotePath]::Combine($remotePath, $file.replace("[", "[[]")) | + | ···················$sourcePath = [WinSCP.RemotePath]::Combine($remotePath, $fileMask) |
| - | $fullNewName = [WinSCP.RemotePath]::Combine($remotePath, $newName) | + | ····················$operationMask = [WinSCP.RemotePath]::EscapeOperationMask($newName) |
| - | $session.MoveFile($fullName, $fullNewName) | + | $targetPath = [WinSCP.RemotePath]::Combine($remotePath, $operationMask) |
| + | $session.MoveFile($sourcePath, $targetPath) | ||
| } | } | ||
| } | } | ||