First of all, I have asked the same question at stack overflow, but I am not sure if it's right over there. That's why I decided to post it here, too.
t'm having a hard time trying to copy the creation and modification date of some files to other files.
I have converted some MXF files to MOV, but unfortunately the new MOV-files don't have the same creation date.
Now I had a look around for similar questions and found different answers, but this seems to be the simplest:
#!/bin/bash
for f in *.MXF; do
touch -r "$f" "${f%MXF}mov"
done
Unfortunately it doesn't work for me – neither with Terminal nor Automator.
I saved the Code with TextEdit. In Terminal I ran chmod+x to make the file executable and put it in the folder where my MXFs and movs are.
But I'm just getting the following error:
touch: *.MXF: No such file or directory
I have also tried mxf instead of MXF.
This is the output of ls- l from the test folder
-rwxrwxrwx 1 username staff 258458160 5 Jan 2014 570_0301.MXF
-rwxrwxrwx 1 username staff 241431870 5 Jan 2014 570_0301.mov
-rwxrwxrwx 1 username staff 974595120 5 Jan 2014 570_0306.MXF
-rwxrwxrwx 1 username staff 911745994 5 Jan 2014 570_0306.mov
-rwxrwxrwx 1 username staff 667679280 5 Jan 2014 570_0308.MXF
-rwxrwxrwx 1 username staff 624468526 5 Jan 2014 570_0308.mov
Because I managed to get the modification date copied it seems that all the files already have the same date, but this doesn't cover the creation date.
Maybe someone could help me out? Will it change the modification and creation date? Because both are important...
Thank you very much in advance and all the best!
EDIT: Got the script working thanks to user3439894.
But it still doesn't update the creation date...
MXF: created 05.01.2014 06:49, modified 05.01.2014 06:50
mov: created 23.06.2016 05:34, modified 05.01.2014 06:50
Is there any way to correct this?
ls -l
for the target directory. Continued in next comment...$filename.MXF
and$filename.mov
files where$filename
matched each set of.MXF
and.mov
files, I tested #1 asfor f in *.MXF; do touch -r "$f" "${f%MXF}mov"; done
and it worked fine! So what problem are you having with it? Note that the.MXF
files cannot be.mxf
as this is case sensitive. Same goes for.mov
, it must be that and not.MOV
. (Which is why I said include the output of ls -l for the target directory.).MXF
and.mov
files? BTW I didn't ask just if the permissions on all the files were the same! I asked for the output ofls -l
for the target directory so I could actually see the names of the files, etc. Additionally this is why I said you have way to much going on in this question and to limit it to one code block and provide Minimal, Complete, and Verifiable example. You can't possibly expect us to help if we don't have all the relevant facts!