I can't seem to figure out this one.
I have a csv file, 2 columns. ColumnsA contains the path to a file and ColumnB the destination of said file. Total rows 1,000.
I will like terminal to loop and move each file located in columnA to the destination in columnB
In terminal, I tried using this:
for file in $(cat ~/downloads/Mover.csv); do mv ...
I can't figure out the next piece of the command. Can you please help?
Raw file Format: csv (comma delimiter) The raw file is as shown in the screenshot. ColumnA contains the path of each pdf that needs to be inserted inside the folder in ColumnB
I'm very new to the world of terminal. Please let me know what I can provide
The CSV format isn't very friendly for UNIX standard tools, but as long as you don't have commas, double-quotes or newlines in your content then you can use this:
#!/bin/bash
while IFS=',' read -r location new
do
mv -i "$location" "$new/"
done < <(sed $'s/\r$//' file.csv)
I'm supposing that new
is a directory