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 62: Line 62:
        {         {
            $newName = $file -replace $pattern, $replacement             $newName = $file -replace $pattern, $replacement
-            Write-Host "$file => $newName" +            if ($newName -eq $file)
-············if ($newName -ne $file)+
            {             {
 +                Write-Host "$file not changed"
 +            }
 +            else
 +            {
 +                Write-Host "$file => $newName"
                $anyChange = $True                 $anyChange = $True
            }             }
Line 121: Line 125:
            {             {
                $newName = $file -replace $pattern, $replacement                 $newName = $file -replace $pattern, $replacement
-                Write-Host "$file => $newName" +                if ($newName -eq $file) 
- +                { 
- ···············$fullName = [WinSCP.RemotePath]::Combine($remotePath, $file.replace("[", "[[]")+                    Write-Host "$file not changed" 
- ···············$fullNewName = [WinSCP.RemotePath]::Combine($remotePath, $newName+                } 
- ···············$session.MoveFile($fullName, $fullNewName)+                else 
 +                { 
 +····················Write-Host "$file => $newName" 
 + ···················$fileMask = [WinSCP.RemotePath]::EscapeFileMask($file
 + ···················$sourcePath = [WinSCP.RemotePath]::Combine($remotePath, $fileMask) 
 +····················$operationMask = [WinSCP.RemotePath]::EscapeOperationMask($newName
 + ···················$targetPath = [WinSCP.RemotePath]::Combine($remotePath, $operationMask
 + ···················$session.MoveFile($sourcePath, $targetPath) 
 +                }
            }             }
        }         }

Last modified: by martin