Modifying File attribute in Bulk, Mac OSX

nish abe
1 min readOct 4, 2016

--

Here is a small snippet of shell script, that could be used if you want to change the file or folder attributes. Such as creation date or modified date.

find YOUR_DIRECTORY_NAME -print | while read filename; do 
# This will change the creation date of all the files under 'YOUR_DIRECTORY' SetFile -d '12/31/2015 04:12:45' "$filename"
# This will change the Modified and Last opened date.
#Format : yyyymmddhhmm
touch -t 201512310537 "$filename" done

Usage:

  1. Save the script in to a .sh file.
  2. Edit the two directory name and date variables as necessary.
  3. Make it executable by chmod a+x scriptName.sh
  4. Either drag in to the terminal app or make Terminal the default app to open.

Note: SetFile is a utility that comes with Xcode.

Reference:

How can I change the date modified/created of a file?

Originally published at nishabe.wordpress.com on October 4, 2016.

--

--

nish abe
nish abe

Written by nish abe

"Curious to know how things work and interested in making things work". https://nishabe.github.io/

No responses yet