S
S
Sergey Pugovkin2019-08-10 16:52:51
linux
Sergey Pugovkin, 2019-08-10 16:52:51

Bulk rename folders?

There are many files and folders:
/home/user/dir1/dir2/file1
...
How can I rename them so that there is one character before the folder name, namely:
/home/user/0dir1/0dir2/file1
?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vreitech, 2019-08-10
@Driver86

for i in $(find /home/user -type d | tac); do mv $i $(echo $i | perl -pe 's/\/([^\/]*?)$/\/0\1/') 2> /dev/null; done

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question