Skip to content
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

Closed
bjohas opened this issue Sep 10, 2016 · 5 comments
Closed

explicitly setting the mod time of a file on drive #726

bjohas opened this issue Sep 10, 2016 · 5 comments

Comments

@bjohas
Copy link

bjohas commented Sep 10, 2016

It is possible to use drive to set the mod time of a file on drive?

Thanks!

@odeke-em
Copy link
Owner

Hello there @bjohas, thank you for the question and welcome to drive.

So let me try to understand your question:
Can drive set the mod time of a file on Google Drive?

  1. Did you mean change it to the current time, as in touch it? If so, yes:
$ 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
  1. Did you mean match the modTime as with a local file? If so, yes:
$ 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

@bjohas
Copy link
Author

bjohas commented Sep 11, 2016

Thanks,

The use case is that when moving photos / videos to SD card, Google drive
picked up the updated time stamps, so the pictures are no longer sorted by
date. There doesn't seem to be a way to adjust these with the web interface.

So it would be possible to pull these, adjust the time stamp on local disk,
and then push?

Because it's a lot of data, I was hoping that through the API you would be
able to set the date remotely say something like:

drive touch -t 201603040000 after.png

On 10 Sep 2016 22:39, "Emmanuel T Odeke" notifications@github.com wrote:

Hello there @bjohas https://github.com/bjohas, thank you for the
question and welcome to drive.

So let me try to understand your question:
Can drive set the mod time of a file on Google Drive?

  1. Did you mean change it to the current time, as in touch it? If so, yes:

$ 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

  1. Did you mean match the modTime as with a local file? If so, yes:

$ 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


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#726 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AHOUauTRdaSj2PpUfn1KcoTzln2FTO3lks5qoyOVgaJpZM4J5wiq
.

@odeke-em
Copy link
Owner

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.

@odeke-em odeke-em added this to the v0.3.8 milestone Sep 11, 2016
@odeke-em odeke-em changed the title (feature request) Can drive set the mod time of a file on drive? explicitly setting the mod time of a file on drive Sep 11, 2016
odeke-em added a commit that referenced this issue Sep 11, 2016
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.
@odeke-em
Copy link
Owner

@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

$ 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

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.

@bjohas
Copy link
Author

bjohas commented Sep 11, 2016

That's great many thanks - will try it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants