I believe there's some similar posts that if I was better at this I could figure out the answer to my own question (This one and this one).
I have a Mac and am using the setfile command from the terminal which works great on an individual file.
setfile -d "08/02/2001 00:00:00" X-09-04.m4v
However, I have hundreds of videos to do this with. I have a file changedate.csv file with all the dates and associated file names in two separate columns (screenshot). The csv is formatted like this:
datenew,id
12/19/1998 12:00:00 AM,X-01/X-01-01.m4v
12/31/1998 12:00:00 AM,X-01/X-01-02.m4v
12/31/1998 12:00:00 AM,X-01/X-01-03.m4v
I then created changedate.sh script that looks like this:
#!/bin/bash
cat changedate.csv | while IFS=, read datenew id;
do
echo 'setfile -d "$datenew" $id'
done
The command setfile requires the date string needs to be wrapped in quotes. This is what messes me up, because when I run sh changedate.sh script from the terminal, it prints out like this:
setfile -d "$datenew" $id
setfile -d "$datenew" $id
setfile -d "$datenew" $id
....
If I remove the quotes around the variable it correctly reads the csv and the output looks like this:
setfile -d 12/19/1998 00:00:00 X-01/X-01-01.m4v
setfile -d 12/31/1998 00:00:00 X-01/X-01-02.m4v
setfile -d 12/31/1998 00:00:00 X-01/X-01-03.m4v
...
This is almost right, but it doesn't work because the date string isn't wrapped in quotes which is required. The final output should look like this:
setfile -d "12/19/1998 00:00:00" X-01/X-01-01.m4v
setfile -d "12/31/1998 00:00:00" X-01/X-01-02.m4v
setfile -d "12/31/1998 00:00:00" X-01/X-01-03.m4v
...
I think I need to use backslashes to get the variable to print with the quotes, but I can't quite figure it out. Thanks for any help!