3 ms·
My approach is something like $ ls / find # tweak until I have a list of things to rename $ for file in $(ls / find...); do echo "mv $file $(echo $file | s
by rich_sasha 5y ago
My approach is something like
$ ls / find # tweak until I have a list of things to rename
$ for file in $(ls / find...); do echo "mv $file $(echo $file | sed ... )"; done # this prints mv commands for renaming, I can inspect them as needed
$ for file in $(); do...; done | sh # execute the renaming
It is inspectable, easy to cancel (just don't pipe to shell), incremental... just needs wrangling with bash etc. which is a bit of a pain.
It works for a bunch of other all-or-nothing commands, which are potentially quite destructive; use a for-loop to generate the commands, tweak until you're happy with it, then pipe to shell.
- da39a3ee 5y agoThanks! I do this but go in and remove the echo. For some reason I hadn’t thought to pipe to a shell interpreter.