Intentionally Changing the "Date Modified" attribute

First, the tip. You can easily modify the date modified attribute of any file or folder by using a simple shell script. It can be applied to a specific file or folder or used to batch change items in a directory/folder.
Use the embedded shell script in Hazel set to bin/sh. The date format for modifying needs to be in the following format: YYYYMMDDhhmm (ie May 12, 2010 at 12:30pm equals 201005121230)
For a specific item:
For a specific directory for batch change:
Note, that you can batch process only certain files within a directory. For example, if you had a folder where you wanted to modify the modified date only for PDF files, you would append a /* .PDF
Now the why.
There are many scenarios where you may want to do this. For example, changing attributes like comments and color label do not affect date modified. Perhaps you want to run an action any time you change any attribute of a file or folder. Or another example is in my case, I am slowly converting all my DVDs to M4v. When I rip the DVD, the modified date is the start of the conversion but it does not continue modifying the folder as it processes. Therefore i could have incorporate a script that when the file is done ripping, change modified date to current date. Many people may choose to just use colors but this provides another option. One last example is that when you download files from the internet, they have various modified dates. Perhaps you want to use this in combination with the date added attribute since date added is only captured (and specific to Hazel) and you want the file to carry the date modified attribute around.
Use the embedded shell script in Hazel set to bin/sh. The date format for modifying needs to be in the following format: YYYYMMDDhhmm (ie May 12, 2010 at 12:30pm equals 201005121230)
For a specific item:
- Code: Select all
touch -mt YYYYMMDDhhmm [path to file or folder]
For a specific directory for batch change:
- Code: Select all
touch -mt YYYYMMDDhhmm [path to file or folder]/*
Note, that you can batch process only certain files within a directory. For example, if you had a folder where you wanted to modify the modified date only for PDF files, you would append a /* .PDF
Now the why.
There are many scenarios where you may want to do this. For example, changing attributes like comments and color label do not affect date modified. Perhaps you want to run an action any time you change any attribute of a file or folder. Or another example is in my case, I am slowly converting all my DVDs to M4v. When I rip the DVD, the modified date is the start of the conversion but it does not continue modifying the folder as it processes. Therefore i could have incorporate a script that when the file is done ripping, change modified date to current date. Many people may choose to just use colors but this provides another option. One last example is that when you download files from the internet, they have various modified dates. Perhaps you want to use this in combination with the date added attribute since date added is only captured (and specific to Hazel) and you want the file to carry the date modified attribute around.