0
如何遞歸地重命名目錄結構?像Batch rename directories in reverse order以相反順序遞歸重命名目錄,Bash腳本
但是,一個簡單的單線?
我試圖做到這一點是徒勞的,這是我試過的命令。
du . | cut -f 2- | sh -c 'mv "$0" echo `date "+%H%M%S%N"` ' {} \;
使用CentOS 6的
如何遞歸地重命名目錄結構?像Batch rename directories in reverse order以相反順序遞歸重命名目錄,Bash腳本
但是,一個簡單的單線?
我試圖做到這一點是徒勞的,這是我試過的命令。
du . | cut -f 2- | sh -c 'mv "$0" echo `date "+%H%M%S%N"` ' {} \;
使用CentOS 6的
你似乎在試圖用find -exec
語法實際上並沒有使用find
。使用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")) \;
這工作!任何避免試圖避免的方法。從重命名操作? –
增加了對「。」的檢查 – Barmar