Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7001561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:49:09+00:00 2026-05-27T20:49:09+00:00

There is a strange behavior with PowerShell when there are square brackets in a

  • 0

There is a strange behavior with PowerShell when there are square brackets in a path. For instance, if you are in the folder:

C:\Some Movie [2011]

which contains an mkv file and you type:

ls *.mkv

nothing is returned! I think the problem lies with the fact that PowerShell tries to do something like:

Get-ChildItem 'C:\Some Movie [2011]\*.mkv'

which fails because [2011] is considered a wildcard. I was able to retrive all mkv from such a folder with the following command:

Get-ChildItem -LiteralPath 'C:\Some Movie [2011]' -Include *.mkv

but when I try to feed those results in a Rename-Item command it fails.

Get-ChildItem -LiteralPath 'C:\Some Movie [2011]' -Include *.mkv | Rename-Item -NewName "movie.mkv"

The same operations in a folder without brackets runs without problems. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:49:10+00:00Added an answer on May 27, 2026 at 8:49 pm

    See my comment on your question (above). this will work if as you expect in case there’s only one mkv file in that folder. Rename-Item doesn’t support LiterlPath (fixed in v3), you can resort to .NET. I also recommend (when you filter for just one extension) to use -Filter instead of Include, it performs faster.

    Get-ChildItem -LiteralPath 'D:\Some Movie [2011]' -Filter *.mkv | Foreach-Object{
        $NewName = Join-Path -Path $_.DirectoryName -ChildPath 'movie.mkv'
        [System.IO.File]::Move($_.FullName,$NewName)
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There is a strange behavior when trying to create string which contains a Hebrew
I'm getting a very strange behavior in MySQL, which looks like some kind of
I have some strange behavior in my iphone app. I have an NSTimer which
There is some strange behaviour in parsing KML produced by Google Earth using a
I've been encountering some strange behavior when trying to find a key inside a
I just noticed a strange behavior which looks like a bug. Consider the following
I have a strange behavior with PHP system function. In this php script there
Can anyone explain this strange behavior found when trying to use sapply and which.min
I have some strange behavior occurring in an ASP.NET application that I am trying
There is a strange behavior I cannot understand. Agreed that float point number are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.