alias meh='for f in *; do printf "mv \"%s\" \"%s\"\n" "$f" "$f"; done > meh.sh; printf "rm meh.sh\n" >> meh.sh'
for f in *; do … done | Loops over every file in the current directory (excluding dot‑files). |
printf "mv \"%s\" \"%s\"\n" "$f" "$f" | Prints a quoted mv command that moves the file to itself |
> meh.sh | Redirects the first set of printed lines into a new file called meh.sh. |
printf "rm meh.sh\n" >> meh.sh | Appends a final line that removes meh.sh. |
; bash meh.sh to the aliasSometimes I have to do a mass rename and this combines the plan creation task in one command, I edit the result file and after execution all is cleaned up.
In other words this creates a todo list as bash file which I can edit to perform the actions I want to do.
Update:
Since I moved to fish shell, here is a fish function, to be put in ~/.config/fish/functions/
function meh
for f in *
printf "mv \"%s\" \"%s\"\n" "$f" "$f"
end > meh.sh
printf "rm meh.sh\n" >> meh.sh
end

