Change File Creation Date

Can I change a file's modification or creation date on iOS?

You can change the modification date by running touch -t <date> <file>, where <date> is the new date and <file> is the file you want to modify. See the man page for touch for the date format, but it's basically like YYYYMMDDhhmm.SS (year, month, day, hour, minute, second).

Example:

$ touch -t 197501020304.05 foo
$ ls -lT foo
-rw-r--r-- 1 userid staff 0 Jan 2 03:04:05 1975 foo

From the documentation, it looks like you can also set the modification date using NSFileManager's setAttributes(_:ofItemAtPath:) method, which lets you set attributes for a given file, including creationDate and modificationDate. However, note that:

As in the POSIX standard, the app either must own the file or directory or must be running as superuser for attribute changes to take effect.

How do I change the file creation date of a Windows file?

Yak shaving for the win.

import pywintypes, win32file, win32con
def changeFileCreationTime(fname, newtime):
wintime = pywintypes.Time(newtime)
winfile = win32file.CreateFile(
fname, win32con.GENERIC_WRITE,
win32con.FILE_SHARE_READ | win32con.FILE_SHARE_WRITE | win32con.FILE_SHARE_DELETE,
None, win32con.OPEN_EXISTING,
win32con.FILE_ATTRIBUTE_NORMAL, None)

win32file.SetFileTime(winfile, wintime, None, None)

winfile.close()

How to change the creation date of file using python on a mac?

I was able to successfully use the subprocess call command to change the creation date of the file with a shell command.

from subprocess import call

command = 'SetFile -d ' + '"05/06/2019 "' + '00:00:00 ' + complete_path
call(command, shell=True)

What can change a file created/modified date?

File properties with regards to the date and time stamps

  • If you copy a file from C:\fat16 to C:\fat16\sub, it keeps the same modified date and time but it changes the created date and time to the current date and time.
  • If you move a file from C:\fat16 to C:\fat16sub, it keeps the same modified date and time and keeps the same created date and time.
  • If you copy a file from C:\fat16 to D:\NTFS, it keeps the same modified date and time but changes the created date and time to the current date and time.
  • If you move a file from C:\fat16 to D:\NTFS, it keeps the same modified date and time and keeps the same created date and time.
  • If you copy a file from D:\NTFS to D:\NTFS\SUB, it keeps the same modified date and time but changes the created date and time to the current date and time.
  • If you move a file from D:\NTFS to D:\NTFS\SUB, it keeps the same modified date and time and keeps the same created date and time.
  • In all examples, the modified date and time of a file does not change unless a property of the file has changed. The created date and time of the file changes depending on whether the file was copied or moved.

For more information see KB299648.

How to edit creation date of MP4 files?

Im not too familiar with it, but ffmpeg seems like an option for just the mp4's.

cmd = 'ffmpeg -i "file.mp4" -codec copy -metadata timestamp="new_time_here" "output.mp4"'
subprocess.call(shlex.split(cmd))

modified from:
https://www.reddit.com/r/learnpython/comments/3yotj2/comment/cyfiyb7/?utm_source=share&utm_medium=web2x&context=3

Batch changing file creation dates in Mac OS Terminal by a set amount of time

A bash loop, instead of trying to fit all this in the exec action of find, would probably ease the coding of your script:

find . -type f -newermt '1/1/2025 00:00:00' -print0 | \
while IFS= read -r -d '' f; do
s=$(stat -f %c "$f")
(( s -= 661361702 ))
d=$(date -r "$s" +%Y%m%d%H%M)
touch -t "$d" "$f"
done

Note: the solution above uses the -print0 option of find and the empty delimiter of read (-d '') to separate the found file names with the NUL character, instead of the default space. This is robust and will work even if you have file names with newlines, tabs, spaces...

How to modify the date-created attribute for multiple files using .csv data?

@Doug Maurer provided an incomplete answer (did not work) so here is the working solution:

$csvfile = 'path/to/csvfile.csv'
$startdate = [datetime]::ParseExact('15/11/2019','dd/MM/yyyy',$null)

Set-Location 'path/to/folder'

Import-Csv $csvfile | ForEach-Object {

#set creationtime
(Get-Item $_.filename).CreationTime = $startdate

#increase date by one day
$startdate = $startdate.AddDays(1)
}

How to modify the file modification date with python on mac?

os.utime can be used to change the modification and/or access time of a file.

It accepts a descriptor or path-like object, and a tuple of times in either seconds or nanoseconds. These specify the latest access and modification times, respectively. For example:

>>> import os
>>> with open('tmp', 'wt') as f: pass
...
>>> result = os.stat('tmp')
>>> print(result.st_atime, result.st_mtime)
1541131715.0 1541131715.0
>>> os.utime('tmp', (result.st_atime, result.st_mtime + 1.0))
>>> result = os.stat('tmp')
>>> print(result.st_atime, result.st_mtime)
1541131715.0 1541131716.0


Related Topics



Leave a reply



Submit