So, I\'ve got a bunch of files with no extension. I want to write a windows batch script that will:
Here's another possible command for renaming files with no extensions recursively (assuming that file paths don't contain spaces):
for /f %i in ('dir *. /b /s /a-d') do rename "%~fi" "%~ni.bla"
Batch version (with doubled %
):
@echo off
for /f %%i in ('dir *. /b /s /a-d') do (
rename "%%~fi" "%%~ni.bla"
)
If file or folder names contain spaces, use this command instead:
for /f "tokens=* delims= " %i in ('dir *. /b /s /a-d') do rename "%~fi" "%~ni.bla"
Batch version:
@echo off
for /f "tokens=* delims= " %%i in ('dir *. /b /s /a-d') do (
rename "%%~fi" "%%~ni.bla"
)
Edit: here's even shorter one-liner that supports spaces in paths:
for /r %i in (*.) do ren "%~fi" "%~ni.bla"
Batch version:
@for /r %%i in (*.) do ren "%%~fi" "%%~ni.bla"