Write Linux script to convert timestamps older than 1.1.1970 to 1.1.1980

I am having problems because some of my files have timestamps that are earlier that 1.1.1970, the Unix start of time convention.

So I would like to write a script that finds all files in home folder and subfolders with timestamps earlier than 1.1.1970 and converts them to 1.1.1980.

I have two commands that work:

and

But I do not know how to chain them so the the output of the first goes to the second. I tried:

But I get an error for each file:

Thanks
Best

Not sure if this is what you are after...
Only got OSX 10.7.5 with me at the moment, this uses BSD date command. My Linux machine is at work so the date format will probably be different...
You could try and create a negative epoch, (using BSD date in this example), something like:-

Last login: Mon Mar 17 23:16:53 on ttys000
AMIGA:barrywalker~> date -j -f "%d-%m-%Y" 19-02-1956 +%s
-437532136
AMIGA:barrywalker~> date -j -f "%d-%m-%Y" 19-02-1965 +%s
-153448929
AMIGA:barrywalker~> date -j -f "%d-%m-%Y" 19-12-1969 +%s
-1042918
AMIGA:barrywalker~> date -j -f "%d-%m-%Y" 31-12-1969 +%s
-6109
AMIGA:barrywalker~> _

And if the result IS negative then set as you require...

I found the following to work when launched in the folder where you want to correct dates. It will automatically work in all eventual subfolders:

Best

Not sure what you're trying to achieve with *.*

This should find and touch all old files under current directory note + give much more efficiency when touching multiple files:

find . -not -newermt 1970-01-01 -exec touch -d 1980-01-01 {} +
1 Like