Differences
This shows you the differences between the selected revisions of the page.
| 2023-01-11 | 2023-01-11 (current) | ||
| not failing when specific file do not require any rename (when the underlying protocol fails noop renames) (martin) | Bug 2157: Batch Rename extensions fails when the filename contain file mask special characters – replaced an ad-hoc user fix with proper general solution (martin) | ||
| 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) | ||
| } | } | ||
| } | } | ||