Reputation: 431
I have a large number of files to be renamed to a fixed pattern on my Windows 8 computer. I am looking for a way so that I can rename the files in a quick way, any way: like any software that does it or any command on command window.
Following is what I need to do:
Original file name: Body Begger Power.docx.htm Need this to be: body-begger-power.html
Upvotes: 0
Views: 893
Reputation: 80023
for /r %i in (.) do if exist "%i\body begger power.docx.htm" ECHO ren "%i\body begger power.docx.htm" body-begger-power.html
from the prompt will scan the tree from .
(the current directory - or substitute the directoryname from which you want to start). This will simply ECHO the filenames detected to the screen - you need to remove the ECHO keyword to actually rename the file.
Upvotes: 1
Reputation: 5504
From the root directory you can try this:
Get-ChildItem -Force -Recurse | Move-Item -Destination {$_.FullName.ToLower() -replace ' ', '-'}
I don't see any pattern for removing the extension. If all files are docx.html and you want them changed to html, you could simply do another replace like this:
Get-ChildItem -Force -Recurse | Move-Item -Destination {($_.FullName.ToLower() -replace ' ', '-') -replace '.docx.htm$', '.html'}
Upvotes: 3