Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



Thanks! I do this but go in and remove the echo. For some reason I hadn’t thought to pipe to a shell interpreter.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: