[英]Recursively rename directory in reverse order, Bash script
How do I recursively rename a directory structure? 如何递归重命名目录结构? Something like Batch rename directories in reverse order
诸如以相反顺序批量重命名目录
But a simple one liner?? 但是一个简单的班轮?
My attempt to do this went futile, Here is the command I tried anyway. 我尝试这样做是徒劳的,这还是我一直尝试的命令。
du . | cut -f 2- | sh -c 'mv "$0" echo `date "+%H%M%S%N"` ' {} \;
Using CentOS 6 使用CentOS 6
You seem to be trying to use find -exec
syntax without actually using find
. 您似乎正在尝试使用
find -exec
语法,而不实际使用find
。 Use find
with its -depth
option to make it return directories from deepest to closest. 使用
find
及其-depth
选项可以使目录从最深返回最接近。
find . -depth -type d ! -name '.' -exec sh -c 'mv "$0" "$0.$(date "+%H%M%S%N")"' {} \;
这个怎么样:
find /path/to/the/directories/location/ -depth -exec mv '{}' $(basename '{}')$(echo $(date "+%H%M%S%N")) \;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.