Batch copy time creation and modification date from files using OSX

2017-01-19 04:29:35

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

  • Since this is not working for you I'm going to suggest you do as fd0 suggested and use SetFile. This will be used in conjunction with GetFileInfo, both of which are a part of Command Line Tools for Xcode.

    You do not need to install the Xcode.app which is ~3.80 GB, just ~160 MB for Command Line Tools for Xcode.

    In Terminal: xcode-select --install

    See How to Install Command Line Tools in OS X Mavericks & Yosemite (Without Xcode), which is also for OS X El Capitan.

    Here is a bash script to use with SetFile and GetFileInfo:

    #!/bin/bash

    for f in *; do

    if [[ -f $f ]] && [[ ${f##*.} == MXF ]] && [[ -f ${f%.*}.mov ]]; then

    cDate="$(GetFileInfo -d "$f")"

    mDate="$(GetFileInfo -m "$f")"

    SetFile -d "$cDate" -m "$mDate" "${f%.*}.mov"

    fi

    done

    2017-01-19 05:20:33
  • Prologue

    I know this is a wrong place to post my batch files, but searching the internet like:allintitle: file "same creation date" - Google Search, I found only this site.

    So, let me introduce and post my batch files here, with which I make "clone files".

    By "clone files" I mean the creation date of files are kept while copying.

    They are:

    bak_0_P2_addTFolderNamemovecopyback_en.bat

    bak_0_P2_addTmovecopyback_en.bat

    bak_0_P2_movecopyback_WOUI.bat

    The bak_0_P2_addTFolderNamemovecopyback_en.bat batch file can be used to make a clone file to a destination folder of your choice, as well as modifying the clone file with the path and the time stamp of the target file, while keeping the creation date of the target file.

    The bak_0_P2_addTmovecopyback_en.bat batch file can be used to make a clone file to a destination folder of your choice, as well as modifying the clone file with the time stamp of the target file, while keeping the creation date of the target file.

    The bak_0_P2_movecopyb

    2017-01-19 05:36:58
  • I tried to upload the files above, to no avail.

    The .bat files and the .reg files can't be uploaded.

    Please see also the: "jpeg-recompress - the output file could optionally have the same creation date and time · Issue #46 · danielgtaylor_jpeg-archive.html"(https://github.com/danielgtaylor/jpeg-archive/issues/46)

    2017-01-19 06:31:36