New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
explicitly setting the mod time of a file on drive #726
Comments
Hello there @bjohas, thank you for the question and welcome to drive. So let me try to understand your question:
$ drive touch after.png before.png doc1.7.png
/codereview-screenshots/before.png: 2016-09-10 21:27:34 +0000 UTC
/codereview-screenshots/doc1.7.png: 2016-09-10 21:27:34 +0000 UTC
/codereview-screenshots/after.png: 2016-09-10 21:27:34 +0000 UTC
$ drive touch after.png
/codereview-screenshots/after.png: 2016-09-10 21:38:07 +0000 UTC
$ drive diff after.png
File: /codereview-screenshots/after.png
* local: 2016-09-10T20:35:46.000Z
* remote: 2016-09-10T21:38:07.000Z
$ drive push after.png
Resolving...
M /codereview-screenshots/after.png
Modification count 1 src: 253.62KB dest: 253.62KB
Proceed with the changes? [Y/n]:y
259707 / 259707 [=============================================================================================================================] 100.00% 0s
$ drive diff after.png && echo "They are the same"
They are the same |
Thanks, The use case is that when moving photos / videos to SD card, Google drive So it would be possible to pull these, adjust the time stamp on local disk, Because it's a lot of data, I was hoping that through the API you would be drive touch -t 201603040000 after.png On 10 Sep 2016 22:39, "Emmanuel T Odeke" notifications@github.com wrote:
|
Oh okay, thanks for the clarification. I see, yeah, drive doesn't yet allow that. However, I just woke up a few hours ago and won't get back up to sleep for a few more others so let me see if I can hack this up. |
Fixes #726. Added custom modification time setting with two different modes: + Custom time with an optional format specifier ```shell $ drive touch --time 20120202120000 ComedyPunchlineDrumSound.mp3 /share-testing/ComedyPunchlineDrumSound.mp3: 2012-02-02 12:00:00 +0000 UTC $ drive touch --format "2006-01-02-15:04:05.0000Z" --time "2016-02-03-08:12:15.0070Z" outf.go /share-testing/outf.go: 2016-02-03 08:12:15 +0000 UTC ``` The default format specifier is 20060102150405. The mentioned custom time format has to be relative to how you would represent "Mon Jan 2 15:04:05 -0700 MST 2006". See the documentation for time formatting here [time.Parse](https://golang.org/pkg/time/#Parse) + Custom time offset from the current clock time. ```shell $ drive touch --duration -30h ComedyPunchlineDrumSound.mp3 outf.go /share-testing/outf.go: 2016-09-10 08:06:39 +0000 UTC /share-testing/ComedyPunchlineDrumSound.mp3: 2016-09-10 08:06:39 +0000 UTC ``` To set that file's modTime to 30 hours ago. For allowable duration formats, see https://golang.org/pkg/time/#Parse.
@bjohas please get the latest from master, I've addressed this with CL #729 and added examples to the README. Now you'll be able to set it, for example like this $ drive touch --time 20120202120000 ComedyPunchlineDrumSound.mp3
/share-testing/ComedyPunchlineDrumSound.mp3: 2012-02-02 12:00:00 +0000 UTC OR
OR $ drive touch --duration -30h ComedyPunchlineDrumSound.mp3 outf.go
/share-testing/outf.go: 2016-09-10 08:06:39 +0000 UTC
/share-testing/ComedyPunchlineDrumSound.mp3: 2016-09-10 08:06:39 +0000 UTC Thank you for filing the issue and hope this helps solve the problem for you. |
That's great many thanks - will try it! |
It is possible to use drive to set the mod time of a file on drive?
Thanks!
The text was updated successfully, but these errors were encountered: