当前位置:网站首页>Use the shell to move all files in a directory to a folder with the name of month and year
Use the shell to move all files in a directory to a folder with the name of month and year
2022-07-22 04:05:00 【aerror】
First create a temporary directory :
mkdir tempformv
Use stat,cut and mkdir Create a folder named month
$stat -c "%y" * | cut -b1-7 | sort | uniq | while read line ;do mkdir tempformv/$line; done
$ls tempformv/
2010-05 2020-05
Generate the command to execute
$ stat -c 'TT="%y";FN="%n"' * | grep -v tempformv | while read line; do eval "$line"; echo "mv \"${FN}\" \"tempformv/${TT:0:7}/\""; done > tempformv/mvops.sh
Check the generated command
cat tempformv/mvops.sh
When there is no mistake , Carry out orders
chmod +x tempformv/mvops.sh
tempformv/mvops.sh
Take the document from temp Move the directory back
mv tempformv/* .
complete
边栏推荐
猜你喜欢
随机推荐
EOS帐号体系
Clean up SYSTEMd logs
[CCF CSP] 201503-1 image rotation
5.1身份认证
第三章课后习题15-23
【CCF CSP】201903-1小中大
互联网大厂为何都爱“送外卖”?
USB of gadget_ function
相对熵、信息熵和交叉熵
Application of stack
【CCF CSP】201503-1图像旋转
2.3线性表的链式表示(2)
Json 格式的接口测试该怎么做?
二叉搜索树与双向链表
3.2队列
关于Hook unistd中open, read, write, close的一些技巧
Shell编程基础及变量
小米10如何安装google play商店
Monai label installation process and use strategy
【黑马早报】苏宁张康阳败诉,被“追债”17亿;恒驰总裁称恒驰大卖已成定局;iPhone14ProMax镜头激凸严重;微信支持全屏输入...