Tips/How To: Use Terminal to keep your job - Macenstein

Tips/How To: Use Terminal to keep your job

It’s happened to everyone who’s ever slacked off at work (and if you are reading this instead of doing something productive, I’ll assume you fall into that category): The boss asks you do do some simple little job (or maybe even a big one) and you totally space out and forget about it.

A week later he walks in and says, “Hey Bonehead, where’s that TPS report? I don’t see it on the server.”

Somehow you’re able to mask your panic, and fumpher out some response like “Oh, I’m sure it’s there, I’ll look for it in a second.”

OK, great. The boss walks away and you bought yourself some time. So now what?

Well, if you’re like me, you hopefully only put off a reasonably minor thing that you can whip up in a couple minutes. The problem now is, your newly created file has today’s creation date, letting everyone know you dropped the ball (once again). Luckily, OS X’s UNIXy goodness has a quick solution to your problem. Let’s change the creation date of the file in Terminal!


Above: Oh crap! November 7th, 2007?! I was supposed to have made this file YEARS ago!

[Now, for the record, I am POSITIVE there are many ways to do this, and probably in fewer steps – there are probably even some apps out there that can do this for you (although I only found some designed to handle jpgs), and more advanced Terminal users can hopefully give us some tips in the comments, but coming from an Adobe After Effects background and not a UNIX one, I am pretty impressed with myself for coming up with this. Plus, I think the steps here will make much more sense to the average Mac user who fears the Terminal.]

Step 1: Set your clock to the time you SHOULD have made the file.


Above: Open up your Date and Time System Prefs, and uncheck the “Set Date and Time Automatically” box.


Above: Now set the clock to the date and time you were supposed to have completed your assignment. Don’t go too far back, McFly! Now hit SAVE.

Step 2: Use Terminal to set the date of your file to the new, wrong, “current” date and time.


Above: Open Terminal (Applications>Utilities>Terminal) and type the following at the prompt: touch ~/Desktop/Picture1.png (obviously, use the name of your file. Mine just happened to be on my desktop). Hit RETURN.


Above: You’ll likely notice your file now says it was created and modified Today. Thats OK.


Above: Go back into your Date and time prefs and re-check the “Set Date and Time Automatically” box.


Above: Your file might still display a date of today in the Finder window. Sometimes selecting a different Finder view, like column will force a refresh of the window. Don’t worry, the date has changed.


Above: Sweet! My file now says I made it over 2 years ago! How could the boss possibly get mad at an employee who shows such foresight!

Obviously, changing the date of a file has many other more “legitimate” uses, such as if you scan in a bunch of photos from 1980 and want them to appear chronologically in iPhoto, or if you need to create an alibi that you were working at the time of the recent murders in town. Anyway, hopefully this tip will help keep at least one of our readers out of jail, and please, if you know of an easier way to accomplish this (specifically to batch modify the dates of a set of files) let us know in the comments!

Comments
13 Responses to “Tips/How To: Use Terminal to keep your job”
  1. Leif says:

    In Terminal, ´man ´ will bring up the manual pages for most command line programs. This reveils the options you can give the touch command:

    touch [-acfm] [-r file] [-t [[CC]YY]MMDDhhmm[.SS]] file …

    The -t argument is the interesting one here: it lets you set your own time, not the one currently in the system. So you might just finish your file and then use touch like this:

    touch -t 200711132041 The_Report.xls

    This will set the access and modification times of the file The_Report.xls to 13 Nov 2007 at 20:41.

  2. Ole-Morten Duesund says:

    You could of course do:

    $ touch -t 200505191029 Picture1.png

    which would achieve the same without messing with the system-clock.

    The man-pages for touch are actually quite helpful if you don’t let it scare you away.

  3. Hey Mac, you’re trying too hard.

    Here is the easier way: touch -mat YYMMDDHHMM [filename]

    If you want to do a batch, create a folder with all of the files you want to change, cd into that folder and type:

    touch -mat YYMMDDHHMM *

    If you don’t want to change date last accessed, remove the a, or the m if you don’t want to change date last modified.

  4. UNIX Master says:

    You can also use the “-t” option to touch so you don’t have to mess with your time server settings in System Preferences.

    Example:

    touch -t 200411011345 file

    Sets the date to 11-01-2004 at 1:45 pm.

  5. UNIX Master says:

    D’oh! several people replied before me!

  6. RevFry says:

    *Sits back and waits for the ‘Update:’ tag to be added*

  7. Hey Rev,

    Nah, I told people to leave better solutions in the comments at the top.
    No need to expend energy with the update tag.
    -The Doc

  8. MC says:

    You kids all try way too hard. Forget the terminal.

    After turning back the date/time, just use the save as command and make an exact copy of the file you’ve been working on.

    It will use the new system date as the create date.

    MC

  9. RevFry says:

    *laugh* I do enjoy the blog. Hope you didn’t get the wrong impression. =)

  10. SI says:

    Should the touch command change the date created too? It only seems to change the date modified for me.

  11. Brian says:

    No, touch only changes date modified and accessed. To change date created, just “Save As…” under the File Menu, and save it as a new name. This will create the same document created whatever time your clock says. (So, yes you will have to change your clock time if you want the Date Created to be in the past.)

  12. Henno says:

    If you installed Xcode (it’s free anyway, so do if you haven’t) you get the command SetFile that lets you change all the times, including the time of creation. Read its man page (after installing), there are several date formats that are supported. This way it’s easy to automate and we do not have to “Save As” or mess around with the clock (which you cannot do without administrative rights anyway, so might not be applicable).

  13. Sam says:

    When i tried doing it by using this command
    touch -t 200505191029 Picture1.png
    it didn’t work (yes I did replace the Picure1.png with my files name.

Leave A Comment

ADVERTISE ON MACENSTEIN

Click here to inquire about making a fortune by advertising your game, gadget, or site on Macenstein.