2

I have many files to move and rename that's under SVN. The naming rule is below.

current path: /root/parent/child_01.html
new path:     /root/parent/child/article_01.html

I know I can rename with "svn move" command but I have about 50 files to rename with sequential numbers.

I found this this. It's very similar to my question but I want to do it with files that's under SVN.

Community
  • 1
  • 1

1 Answers1

0

The basic pattern would be the same as for the answers to the question you mentioned:

  1. Find all files
  2. Craft command
  3. Execute command

For your specific situation, this would be something like:

find /tmp -regex ".*_\d+\.html$" -regextype posix-extended -type f -print0 | # find all html files with a number in the name
gawk 'BEGIN{ f = gensub(/(.*)(_\d+\.html)/, "\\1/article\\2", "g"); printf "svn mv %s %s\n", $0, f}' | # build svn command
bash # run command

NB: As a general warning, test scripts like this first by echoing instead of executing. I have not tested this as I don't have a shell at hand.

Community
  • 1
  • 1
SQB
  • 3,926
  • 2
  • 28
  • 49