[Question] Bulk renaming files with parentheses and kanji in filenames.
Like in title, I have a bunch of files I want to quickly rename (delete part of name to be precise). Sounds simple. I'm using Powershell ISE 3.0.
I navigate to the folder with files to be renamed, and execute this command chain:
Get-ChildItem -rec | ForEach-Object -Process {$_.FullName} | move-item -literalpath $_ $_.Name.Replace("(生け花) ", "")
That returns error:
You cannot call a method on a null-valued expression.
At line:1 char:1
+ Get-ChildItem -rec | ForEach-Object -Process {$_.FullName} | move-item -literalp ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
I'm using Move-Item command, because Rename-Item wouldn't even properly execute with parentheses in filename.
This is literally my first time using Powershell, and I just bungled it up from random posts on the internet.
What exactly am I doing wrong?
Posted Dec 17, 2013, 2:45 PM UTC
36
I'm getting
for each file.
Try running through it first without using one-liners to make sure you're getting the values you want
Then
And then
It executes without errors, but doesn't change filenames. All paths are correct from what I can see.
I am using this temporary directory with only two files, so if something goes haywire, I won't lose all of them.
Ah, well, I commented out the renaming part so that's not too surprising.
Try this: