Storage remote date/time sort & manipulation

On the rclone remote display end, is there any native rclone command options to sort the date/time of output or change the date/time format ? i.e. unix epoch times ?

for example for output

rclone -q lsd gdrive1:centos7.localdomain/copy-nginxconf                                                                           
          -1 2016-10-28 23:09:27        -1 autoprotect
          -1 2016-10-28 23:09:23        -1 conf.d
          -1 2016-10-28 23:09:19        -1 ssl
          -1 2016-10-28 23:09:14        -1 phpfpmd

to sort by date ascending directory listing

rclone -q lsd gdrive1:centos7.localdomain/copy-nginxconf | sort -k2,3
          -1 2016-10-28 23:09:14        -1 phpfpmd
          -1 2016-10-28 23:09:19        -1 ssl
          -1 2016-10-28 23:09:23        -1 conf.d
          -1 2016-10-28 23:09:27        -1 autoprotect

also is there any option flag to just display date/time and directory name ? without the -1 columns ?

basically trying to determine age of the remote files for backup scripts etc :slight_smile:

i.e. if remote directory is older than 7 days etc

That would be a no to all of those! rclone listing is a bit primitive at the moment!

Make an issue on github with the flags you’d like to see.

You can use the --max-age and --min-age flags in directory listings which might help (though they don’t apply to directories, only files).

1 Like

yeah would be nice to have additional flags for this so will submit an issue on github

was trying to manipulate myself but would easier if there were flags for such :slight_smile:

rclone -q lsd gdrive1:
          -1 2016-10-28 23:08:06        -1 centos7.localdomain
          
rclone -q lsd gdrive1: | awk '{print $2,$3}'
2016-10-28 23:08:06

date "+%s" -d "$(rclone -q lsd gdrive1: | awk '{print $2,$3}')"
1477696086

so

today=$(date +%s)
remote_date=$(date "+%s" -d "$(rclone -q lsd gdrive1: | awk '{print $2,$3}')")
remote_age=$(($today-$remote_date))
remote_dirname=$(rclone -q lsd gdrive1: | awk '{print $5}')
echo "Remote directory $remote_dirname is $remote_age seconds old"
Remote directory centos7.localdomain is 89682 seconds old

thinking out aloud for possible flags

--epoch

to display remote date/timestamps in epoch time format

--epoch-only

to display remote date/timestamps only with directory or file name and no other attribute columns. So equivalent to but with epoch time format

rclone -q lsd gdrive1: | awk '{print $2,$3, $5}'
2016-10-28 23:08:06 centos7.localdomain

--time-only

similar to --epoch-only so only date/timestamp and directory/file listed

--sort-time with {asc|desc}

sort output by time ascending or descending

once i sort out my thoughts, i’ll submit a issue on github :slight_smile:

The usual way I do this is look for prior art and borrow that.

So if rsync has a flag then I use that in rclone.

So I’d probably look at stealing the flags from ls such as -sort and none (-U), size (-S), time (-t), version (-v), extension (-X)

ls has a time-style option. I’d use go time.Format specifier strings for anything user defined.

Another idea would be for ls to take a --format option which would be a go template format specifier for making up your own listings.

1 Like

sweet that would be perfect