How can I easily bulk rename files with Perl?

后端 未结 9 1220
一生所求
一生所求 2021-01-05 17:25

I have a lot of files I\'m trying to rename, I tried to make a regular expression to match them, but even that I got stuck on the files are named like:

<
9条回答
  •  轮回少年
    2021-01-05 17:46

    Is this a one-time thing? If so, I'm going to suggest something that might seem to be a cop out by many programmers here:

    Pipe the output of your command (find -type d | sort -r | grep ' [1-9][0-9]$') to a file and use an editor along with some global search/replace magic to create a script that does the renames.

    Then throw away the script.

    There's little fuss and little chance that you'll end up shooting yourself in the foot by having some attempt at a clever (but inadequately debugged) one-liner go off into the weeds on your files.

提交回复
热议问题