I have a directory with around 2000 files in it.
~/
-File 1.pdf
-File2.pdf
-Another file 1.pdf
-File3.pdf
-Someother file.docx
-Yeanother.pdf
I have mapped each file with the account it relates to. This mapping is in a CSV file.
File Name & Destination
File 1.pdf | CompanyAccount1
File2.pdf | CompanyAccount1
Another file 1.pdf | CompanyAcountA
File3.pdf | CompanyAccount5
Someother file.docx | AnotherAccount2
Yeanother.pdf | CompanyAccount1
I would like to move the files from the main directory into sub-directories based on the account name based on the csv (or text file).
Desired Result
~/
-CompanyAccount1
--File 1.pdf
--File2.pdf
--Yeanother.pdf
-CompanyAcountA
--Another file 1.pdf
-CompanyAccount5
--File3.pdf
-AnotherAccount2
--Someother file.docx
Ideally it would be something as simple as mv < file-and-destination.csv
, but I can't get it to work. I've tried xargs mv < renaming.txt
, but it doesn't work as expected (some were moved and then everything else was moved into a single directory).