
[英]Batch file to find newest file in folder then copy and rename it to another folder
[英]Batch Scripting: Copy the 10 newest files to another folder
我正在尝试将一个文件夹中的10个最新文件复制到另一个文件夹,并在此过程中重命名它们。 所以dir01包含file01 file02 file03 file04等等...我想复制10个最新文件并将其重命名,例如image-01.jpg,到dir02等等。 我刚开始批量生产,想知道是否有人可以帮助我? 我目前有一个脚本可以复制最新文件,但是只能复制一个文件。
提前致谢。
我会用这样的东西
enter #!/bin/bash
for file in "$(ls -t|head -n10)"
do
cp "$file" new_directory/
echo "$file"
done
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.