4 ms·
Yep. Technically the request included recursive rename, and to avoid renaming directories, but gosh that's not hard: dir -rec -file | rni –newname { $_.nam
by latkin 11y ago
Yep. Technically the request included recursive rename, and to avoid renaming directories, but gosh that's not hard:
dir -rec -file | rni –newname { $_.name –replace "_"," " }
Edit: Oops, request did not include recursive, the original sample solution did.
FWIW top Google results for "unix recursively rename files" give below solutions (slightly different scenarios but you get the idea). Not particularly shorter, or less cryptic:
find . -iname "*dbg*" -exec rename _dbg.txt .txt '{}' \;
shopt -s globstar nullglob
rename _dbg.txt .txt **/*dbg*
- tacos 11y agoY'all are still missing the point. We live in a world where people use CoffeeScript to avoid typing a semicolon. When you Google a PowerShell problem the Google results come back looking insane. You can play code golf here all you want but even this version looks nuts to outsiders. It's a cultural problem. You don't solve it by shouting subtly-differing versions of your culture, louder.
- UK-AL 11y agoHis 'rename' wasn't recursive. <Quote>Y'all are still missing the point. We live in a world where people use CoffeeScript to avoid typing a semicolon. When you Google a PowerShell problem the Google results come back looking insane. You can play code golf here all you want but even this version looks nuts to outsiders It's a cultural problem. You don't solve it by shouting subtly-differing versions of your culture, louder. ".</Quote> You're not getting the point. Powershell is just short, and sometimes shorter if you actually learn it. "When you Google a PowerShell problem the Google results come back looking insane" - This is a problem with the age of powershell. Bash has been around for ever, so there is lots of good quality content on the web.
- tacos 11y agoThat wasn't what I Googled. And Microsoft is announcing bash and Linux shell subsystems today for Windows so y'all are really missing the point. Maybe dev goes one way and ops goes another. But probably not. I'm not betting on Powershell.