【发布时间】:2019-01-02 07:50:54
【问题描述】:
我有一个目录,里面有大约 2000 个文件。
~/
-File 1.pdf
-File2.pdf
-Another file 1.pdf
-File3.pdf
-Someother file.docx
-Yeanother.pdf
我已将每个文件映射到与其相关的帐户。此映射位于 CSV 文件中。
文件名 & 目标
File 1.pdf | CompanyAccount1
File2.pdf | CompanyAccount1
Another file 1.pdf | CompanyAcountA
File3.pdf | CompanyAccount5
Someother file.docx | AnotherAccount2
Yeanother.pdf | CompanyAccount1
我想将文件从主目录移动到基于 csv(或文本文件)的帐户名称的子目录中。
期望的结果
~/
-CompanyAccount1
--File 1.pdf
--File2.pdf
--Yeanother.pdf
-CompanyAcountA
--Another file 1.pdf
-CompanyAccount5
--File3.pdf
-AnotherAccount2
--Someother file.docx
理想情况下,它会像mv < file-and-destination.csv 这样简单,但我无法让它工作。我试过xargs mv < renaming.txt,但它没有按预期工作(一些被移动,然后其他所有东西都被移动到一个目录中)。
【问题讨论】:
-
请分享您的尝试...
-
还有一些工作示例......当您说文件“与”帐户“相关”时,您的意思是“拥有”吗?
-
在 CSV 上循环,读取值(帐户和文件名),如果不存在则创建目录“帐户”,将“文件名”移动到该目录中,继续循环。没有尝试,没有免费代码:-)
-
我对此做了很多变体,xargs -I {} mv {}