EliziumNet / RexFs

Regular expression based Bulk File/Directory renamer
MIT License
4 stars 2 forks source link

remy: rename-FsItem should check last error to ensure rename op was ok #26

Closed plastikfan closed 3 years ago

plastikfan commented 3 years ago

Needs to check last error after invoking renam-item, because it can fail, eg if a renamed directory is open in another application and therefore locked, the rename operation will fail. Currently, rename-FsItem does not check the last error code and assumes the rename proceeds without error and returns $null implicily via a call to Get-Item on the intended destination path.

The last error description can be accessed via $error[0] and an Exception needs to be thrown that includes the error denoted in $error[0].

If the folder is currently open in another app, like an explorer, the error will be access denied.

Actually, the fix is simpler than this. rename-FsItem should not be catching exceptions and should let Rename-Many handle the exception.

plastikfan commented 3 years ago

discovered a slight apprently inconsequential error in use-actionParams, there is some use of the variable $_exchange which is declared in the parent scope. Should be using the local version passed $exchange.