我完全吮吸Bash / Python / Ruby / Perl脚本(需要练习/学习更多),所以我要求一点帮助:-)
我需要将约60个Maildirs的内容移动到其父文件夹,并在Linux机器上重命名该父文件夹,当然,我可以使用'mv *。[^。] * ../'来执行此操作。其重复多个文件夹,我想完成。
所以目前我有/some/folder/prefix-user.name/Maildir/,我想最终:
/some/folder/user.name/其中包含Maildir的内容。
两个单独的脚本将是好的,实际上它可能会更好,所以我有多个例子来学习如何做这种重复的function自动化:-)
提前谢谢你的帮助!
最近我一直在做这种事情。 (移动用户文件夹中的文件!)
for u in $(ls -1 /some/folder/) do #give some feedback echo "Working on $u" # move the contents of Maildir up a level mv $u/Maildir/*.* $u #generate the new name for the user folder newname=$(echo $u | awk -F "-" '{print $2}') # move the user fodler to the new name mv $u $newname done;