Title: `Remove-Item` should provide `-File` parameter · Issue #20637 · PowerShell/PowerShell · GitHub
Open Graph Title: `Remove-Item` should provide `-File` parameter · Issue #20637 · PowerShell/PowerShell
X Title: `Remove-Item` should provide `-File` parameter · Issue #20637 · PowerShell/PowerShell
Description: Summary of the new feature / enhancement Current Situation Currently, trying to recursively delete files with a particular file extension also deletes all sub directories in a call like this: Remove-Item * -Recurse -Filter '*.java' Examp...
Open Graph Description: Summary of the new feature / enhancement Current Situation Currently, trying to recursively delete files with a particular file extension also deletes all sub directories in a call like this: Remov...
X Description: Summary of the new feature / enhancement Current Situation Currently, trying to recursively delete files with a particular file extension also deletes all sub directories in a call like this: Remov...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/20637
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`Remove-Item` should provide `-File` parameter","articleBody":"### Summary of the new feature / enhancement\r\n\r\n# Current Situation\r\n\r\nCurrently, trying to recursively delete files with a particular file extension also deletes all sub directories in a call like this:\r\n\r\n```ps\r\nRemove-Item * -Recurse -Filter '*.java'\r\n```\r\n\r\n## Example\r\n\r\n```ps\r\nPS C:\\Temp\\Test> Get-ChildItem * -Recurse -Name -Filter '*.java'\r\ntrunk\\MyProject\\File1.java\r\ntrunk\\MyProject\\File2.java\r\ntrunk\\MyProject\\MyFolder\\File1.java\r\ntrunk\\MyProject\\MyFolder\\File2.java\r\n\r\nPS C:\\Temp\\Test> Remove-Item * -Recurse -Verbose -Filter '*.java'\r\nVERBOSE: Performing the operation \"Remove Directory\" on target \"C:\\Temp\\Test\\Something\".\r\nVERBOSE: Performing the operation \"Remove Directory\" on target \"C:\\Temp\\Test\\Something\\trunk\".\r\nVERBOSE: Performing the operation \"Remove Directory\" on target \"C:\\Temp\\Test\\Something\\trunk\\MyProject\".\r\nVERBOSE: Performing the operation \"Remove Directory\" on target \"C:\\Temp\\Test\\Something\\trunk\\MyProject\\MyFolder\".\r\nVERBOSE: Performing the operation \"Remove File\" on target \"C:\\Temp\\Test\\Something\\trunk\\MyProject\\MyFolder\\File1.java\".\r\nVERBOSE: Performing the operation \"Remove File\" on target \"C:\\Temp\\Test\\Something\\trunk\\MyProject\\MyFolder\\File2.java\".\r\nVERBOSE: Performing the operation \"Remove File\" on target \"C:\\Temp\\Test\\Something\\trunk\\MyProject\\File1.java\".\r\nVERBOSE: Performing the operation \"Remove File\" on target \"C:\\Temp\\Test\\Something\\trunk\\MyProject\\File2.java\".\r\n\r\nPS C:\\Temp\\Test> Get-ChildItem\r\nPS C:\\Temp\\Test>\r\n```\r\n\r\n# Desired Situation\r\n\r\n(a) Directories not matching the filter should not be deleted.\r\n\r\n(b) Add a `-File` parameter, providing the same functionality as the [`Get-ChildItem`](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-childitem) [`-File`](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-childitem#-file) parameter.\r\n\r\n# Version\r\n```\r\nPS C:\\Temp\\Test> $psversiontable\r\n\r\nName Value\r\n---- -----\r\nPSVersion 7.3.9\r\nPSEdition Core\r\nGitCommitId 7.3.9\r\nOS Microsoft Windows 10.0.19045\r\nPlatform Win32NT\r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}\r\nPSRemotingProtocolVersion 2.3\r\nSerializationVersion 1.1.0.1\r\nWSManStackVersion 3.0\r\n```\r\n\r\n### Proposed technical implementation details (optional)\r\n\r\nSee above.","author":{"url":"https://github.com/SetTrend","@type":"Person","name":"SetTrend"},"datePublished":"2023-11-06T13:48:37Z","url":"https://github.com/PowerShell/PowerShell/issues/20637"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2805c186-4c1b-2102-5a21-df44501661af |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9798:387B4E:AA6130:F44FB3:6AFDA069 |
| html-safe-nonce | 98afccff332a29b2bc812925b21c03994d82349ff3b2410405e180aea4555a9c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5Nzk4OjM4N0I0RTpBQTYxMzA6RjQ0RkIzOjZBRkRBMDY5IiwidmlzaXRvcl9pZCI6IjczMTAzMjUwNDAxNTM0NjkwMzMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 66ada1b1351e8365d6f3d9f03b27f024be84fa18a653b1b10e072e6a34140277 |
| hovercard-subject-tag | issue:1979205066 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/20637/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8a78936511db14c8abaa4c1c815bc68f3cff941f4823692d9f8d1bd90e955827/PowerShell/PowerShell/issues/20637 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8a78936511db14c8abaa4c1c815bc68f3cff941f4823692d9f8d1bd90e955827/PowerShell/PowerShell/issues/20637 |
| og:image:alt | Summary of the new feature / enhancement Current Situation Currently, trying to recursively delete files with a particular file extension also deletes all sub directories in a call like this: Remov... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | SetTrend |
| hostname | github.com |
| expected-hostname | github.com |
| None | bc86424ef34a73b386237872800e922d149d65ba907f63d6f150a2dcb8433bea |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 927a6c5ab1c32b38830f1b9d3050c0b9e9aa92e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width