Change creation date attribute?

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Re: Change creation date attribute? Tue Nov 26, 2013 11:45 am • by Plex
FIXED

From this site I learned that I needed to add a period (".") between "mm-" and "ss" in my renaming format so that it would map properly to the touch command: mm-.ss

Code: Select all
Rename with pattern Date Pattern, in format YYYY-MM-DD-hh-mm-.ss)-(extension)


Works like a dream! Thanks all. Hazel purchase forthcoming!
Plex
 
Posts: 14
Joined: Mon Nov 18, 2013 8:02 pm
Location: Colorado

Re: Change creation date attribute? Wed Mar 05, 2014 8:07 pm • by piersdd
I found touch wouldn't always work. Sometimes, if the creation date was way out already, it would ignore it.
So, using /usr/bin/setfile, which requires the Apple Developer command line tools, I would get a more consistent result.
(MacOS X Mavericks auto-prompts to install the Apple Developer command line tools)

Code: Select all
# Take filename, YYYY-MM-DD-New Name.pdf and
# - adjust the creation date using /usr/bin/setfile -d
# - adjust the modification date using /usr/bin/touch
# - rename the file to New Name.pdf using /bin/mv
 
filename_without_path=$(basename "$1")
extension="${filename_without_path##*.}"
filename_without_extension_or_path="${filename_without_path%.*}"

YYYY=$(echo "$filename_without_extension_or_path" | awk -F "-" '{print $1}')
MM=$(echo "$filename_without_extension_or_path" | awk -F "-" '{print $2}')
DD=$(echo "$filename_without_extension_or_path" | awk -F "-" '{print $3}')
NNAME=$(echo "$filename_without_extension_or_path" | awk -F "-" '{print $4}')

# Change creation date
/usr/bin/setfile -d "$MM/$DD/$YYYY" "$1"
# Change modification date to Today/Now
/usr/bin/touch "$1"
# Rename file
/bin/mv "$1" "$NNAME"
piersdd
 
Posts: 1
Joined: Wed Mar 05, 2014 7:33 pm

Re: Change creation date attribute? Sat Apr 09, 2016 7:21 pm • by DaveB
piersdd wrote:I found touch wouldn't always work. Sometimes, if the creation date was way out already, it would ignore it.
So, using /usr/bin/setfile, which requires the Apple Developer command line tools, I would get a more consistent result.
(MacOS X Mavericks auto-prompts to install the Apple Developer command line tools)


THANK YOU! This is just what I needed for the last piece of my NeatWork Migration scripts. I'm migrating a NeatWorks archive that includes documents scanned starting back in 2007. I had everything I needed in Hazel except this last piece, to re-date the creation date of each file to the original date. Now I have a clear path to migrate from the NeatWorks archive and "fire" Neatworks as my Paperless solution.

I've grown unhappy with the Mac version of NeatWorks since they've stopped providing upgrades to the Mac version of the software and their legacy scanner driver. I'm working on a new workflow to use either the file system or Evernote. But the first piece was to see if I could export existing content from the Neat archive package file, with detail. With the help of Hazel and your embedded date shell-script, I'm there!

Thanks again.

-DaveB
DaveB
 
Posts: 25
Joined: Sat Apr 02, 2016 7:56 pm

Previous

Return to Support