将带有路径的文件名与文件一起移动到目录中的文件 [英] Move file names with path to a file in a directory along with files
本文介绍了将带有路径的文件名与文件一起移动到目录中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只在使用以下文件的文本文件中移动文件名:
I was moving only the file names in a text file which was working using:
cd /data/sources/
find $PWD -type f -name "Asset_*">> /data/processing/asset_files.txt
但是,我还需要:
- 还将
Asset _ *
文件移动到/data/processing/
中. - 将前1000个文件移动到
/data/processing/
.
- Move
Asset_*
files also in/data/processing/
. - Move first 1000 files into
/data/processing/
.
如何添加这两件事?
推荐答案
重构@Dominique的答案,您可以使用find命令并移动文件.这可能会花费很多时间(取决于文件数)命令就像:
Refactoring answer of @Dominique you can use find command and move the files. THis can take a lot of time (depend of number of files) And the command is like:
cd /data/sources/
find $PWD -type f -name "Asset_*" -exec mv {} /target_dir \;
如果您想精确移动1000个文件,可以使用类似的方法
If you want to move exactly 1000 files you can do it with something like
a=1
cd /data/sources/
for i in $PWD/Asset_*
do
mv "$i" /target_dir
a=$(($a + 1))
if [ "$a" -gt 1000 ]
then break
fi
done
这篇关于将带有路径的文件名与文件一起移动到目录中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文