[英]Is there a way to reverse flatten a directory? Python or shell?
Is it possible to do a reverse flatten on a directory?是否可以对目录进行反向展平?
Current Structure:当前结构:
/dir1
/dir2
/dir3
/main_dir
|
--- subdir1
|
--- subdir2
|
-----file1.txt
Target Structure:目标结构:
/main_dir
|
--- subdir1
|
--- subdir2
|
-----file1.txt
Thank you.谢谢你。
you can move the directory to another path like so您可以像这样将目录移动到另一个路径
mv /dir1/dir2/dir3/main_dir /
this move the main_dir
to the /
path这将main_dir
移动到/
路径
Python: Python:
import shutil
shutil.move('/dir1/dir2/dir3/main_dir', '/main_dir')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.