I'm trying to copy the 10 newest files in a folder to another folder and rename them in the process. So dir01 contains file01 file02 file03 file04 and so on... I want to copy the 10 newest files and rename them, so say image-01.jpg, to dir02 and so on. I'm pretty new to batch and was wondering if anyone could help me out? I currently have a script to copy the newest file, but only that one file.
我正在尝试将文件夹中的10个最新文件复制到另一个文件夹,并在此过程中重命名它们。所以dir01包含file01 file02 file03 file04等等......我想复制10个最新的文件并重命名,所以说image-01.jpg,dir02等等。我是批处理的新手,想知道是否有人可以帮助我?我目前有一个脚本来复制最新的文件,但只有一个文件。
Thanks in advance.
提前致谢。
1 个解决方案
#1
0
I would use somwthing like this
我会用这样的东西
enter #!/bin/bash
for file in "$(ls -t|head -n10)"
do
cp "$file" new_directory/
echo "$file"
done
#1
0
I would use somwthing like this
我会用这样的东西
enter #!/bin/bash
for file in "$(ls -t|head -n10)"
do
cp "$file" new_directory/
echo "$file"
done