I'm trying to mass rename a bunch of 1000 *.json files in a folder but I'm having trouble actually executing the script.
Each file is incrementally named:
"Image 1.json", "Image 2.json, ..... "Image 1000.json"
I want to rename them as integers (-1) without extensions (I know it sounds weird, but gotta do it).
So
- "Image 1.json" becomes: 0
- "Image 2.json" becomes: 1
- "Image 423.json" becomes: 422
- "Image 1000.json" becomes: 998
Just so I don't mess this up I create a test folder with only the first 10 files:
And I saved it: C:\test\testfolder
Here's my script
$files = Get-Content
$x = 0
foreach ($file in $files) {
Rename-Item $file $x
$x++
}
I save the script in: C:\test\rename.ps1
In PowerShell I navigate to the directory:
cd c:\test\testfolder\
Then in PowerShell I run the script
C:\test\rename.ps1
Power shell then gives me this ("Its asking me for input and I am entering numbers...it goes nowhere):
What am I doing wrong?