Keep "Date Created/Modified" Info from Before Encode - Video WTF - Questions and answers about video production, video cameras, editing, publishing, et cetera. most recent 30 from http://videowtf.com 2010-07-30T18:37:20Z http://videowtf.com/feeds/question/737 http://www.creativecommons.org/licenses/by-nc/2.5/rdf http://videowtf.com/questions/737/keep-date-created-modified-info-from-before-encode Keep "Date Created/Modified" Info from Before Encode Grant 2010-01-27T01:04:15Z 2010-02-22T01:44:53Z <p>I had a bunch of video files (.TODs - mpgv video, mpga audio) that were useless unless I converted them, so I did. </p> <p>Once I converted them, the "Date Created" and "Date Modified" (that you see in the Finder) were obviously changed, since new files were created from the old ones. Is there an easy way to move the data for the dates from the old files to the new ones (preferably not manually)? The project I am doing is chronology-dependent, so being able to sort by date is essential. </p> <p>I would be willing to convert all the files again, if there was a way to retain the info through conversion in either a different converter.</p> <p>I used ffmpegx with a program called "Quick Batcher" so I could batch convert the files. I'm on a Mac, with Mac OS X 10.6.2 (Snow Leopard). Any help would be really appreciated!</p> http://videowtf.com/questions/737/keep-date-created-modified-info-from-before-encode/784#784 Answer by lImbus for Keep "Date Created/Modified" Info from Before Encode lImbus 2010-02-19T09:44:01Z 2010-02-22T01:44:53Z <p>the unix command <code>touch</code> is avaiable on your mac. this tool allowes you to change the <code>date created</code> and <code>date modified</code>-fields of your files in the filesystem (is suppose this is what finder evaluates).</p> <p>If you have a lot of files, and you still can correlate them (If nameA.tod has become nameA.mov), you can easily script this command with a little bit of bash magic, applying the .toc-dates to the .mov-files.</p> <p>Otherwise, you can still do that manually:</p> <pre><code>touch -r nameA.tod nameA.mov </code></pre> <p>This will transport access and modification time from the tod-file to the mov-file. Also, you can specify the timestamp yourself:</p> <pre><code>touch -t 200905172359 thefile </code></pre> <p>will change the access and modification date to the 17th of may last year, the minute before midnight.</p> <p>Type "man touch" to see all options.</p> <p>BEWARE: If you run touch on a file without parameters, it will update it to the current time. This might break your history and logic. If you mistype the filename, touch will create the file (with size 0)</p> <p>EDIT: There we go, updating to explain how to script this. In unix and bash, there is usually two ways to base a loop on files. One way is the <code>find . -exec echo {} \;</code> which gets just a bit too complicated in this case. The other way is to write a shell script file and program a proper loop:</p> <pre><code>#! /bin/sh for oldname in *.tod; do namebase=`echo "$oldname" | cut -d'.' -f1` touch -r $oldname $namebase.mov done </code></pre> <p>Let's explain this quickly:</p> <ul> <li>the first line is the so called "she bang line" which tells the system how to run this script. It is precisely a comment indicating the path to the executable needed.</li> <li>the <code>for</code> loop (everything indented is "in" the loop) helps us doing a task repeatedly. </li> <li>every dollar sign indicates the use of a variable, where definitions of a variable do not need a special character.</li> <li>the way we ask for the <code>for</code>-loop, the content will be run for every file matching the pattern, so every file ending on .tod. The filename of the current instance can be found in the variable "oldname", since this is the name of the former file, before the conversion.</li> <li>the first line "in" the loop stores the the base of the filename without extension, so we can add another in the second line.</li> <li>the second line is the <code>touch</code> command as explained before, just applying the variables</li> <li>the last line just finishes (or "closes") the loop.</li> </ul> <p>Now, let's see the steps we need to get this running:</p> <ul> <li>The contents as above need to be copied in a file, preferably in the directory where the files reside. If needed otherwise, the script need to be adapted.</li> <li>Preferably, this file is called <code>something.sh</code>, like <code>retoucher.sh</code> or <code>transferTimestamps.sh</code></li> <li>This file needs to be made executable. For this, we need a shell/terminal/commandline in the directory where the file resides, but I take this for granted, since you got already this far (and for other reasons). To render the file executable type and execute <code>chmod +x retoucher.sh</code> (it adds the eXecutable flag to the file 'modes')</li> <li>then already the file can be executed: It needs just a little prefix to it's name, so that the system knows where to find it, the local directory is never assumed: executing <code>./retoucher.sh</code> will do the trick (without any messages of success).</li> </ul> <p>Pfew, I hope that helps :) If not, feel free to tell my why in the comments, I'll try to repair and refine this description.</p>