How to rclone touch all files?

How can I rclone touch many files - for example all in a given folder? I'm trying to fix some modtimes that got corrupted by a bug at some point.

touching a single file is no problem, however...
rclone touch F:\modtimefix\1KFILES -t "2000-01-01T00:00:01"
results in an access denied for some reason. I am not exactly sure what that refers to (must be something other than the files), but I expect something simple in my syntax here is wrong.

EDIT: adding -C (don't create new files) fixed whatever it was trying to access - but then it just finishes with 0 actions taken, so that wasn't all that helpful...

Any suggestions?

(No files touched without their explicit consent... I just want to gently fondle a lot of them at once is what I'm sayin' hurr hurrr :wink: )

rclone touch only deals with one file at once at the moment - it can't take a list of files.

Maybe with a flag it could do all files in the directory that you give it (or --files-from etc). This would be reasonably easy to add and is the way a lot of rclone commands work. Perhaps that should even be the default if you supply the -C flag.

Aha! Well no wonder I was having problems then. I was starting to suspect that.

I think I'll just have to script it then. I think I have something almost done for powerscript. I'll post it here when done in case anyone else finds it useful.

It is probably most efficent to mount the remote then use rclone touch on the files in the mount.

Yea I'm thinking I will just rclone mount --min-age 400y (to only get files that need fixing)

then run this powershell on them
dir . -recurse -filter "*.*" | touch -t 0001010101
(not yet tested).
EDIT: didn't end up using this - see below

Thankfully I have a backup I can do this on first so I don't screw myself =P

i am not powershell user but i know that with cmd, be default, dir will not see hidden and system files.

and if you do screw yourself, post the pics, please!

The best thing I could come up with in the end was:
Get-ChildItem -Force F:\MODFIX * -recurse | ForEach-Object{$_.LastWriteTime = Get-Date}

Unfortunately this does not seem to work properly through the mount
So my only remedy here will be to download the affected files (filtered with --min-age 400y)
then fix them
and re-upload

Very much a hassle, but in my case it's just a couple hundred GB so it's doable.

Maybe there would be room in the future for a rclone touchall that takes a directory rather than a file (and has a recursive option). @ncw

  1. the problem with powershell is the expectation of using Get-ChildItem and | and expect to write complex code.
  2. you do not need to use rclone mount.

let's say that the local source = c:\folder\
and the remote is gdrive:bucket\

in a loop for each local file, you need two variables

  1. strip out c:\ and create a variable with the remainder of the filepath such as source=folder\file
  2. create a variable destpath = gdrive:bucket\ + source
  3. rclone.exe touch destpath -t "2000-01-01T00:00:01"

Yea, I see where you are going with that, and that would probably wok fine.
But I'm starting to lose focus now and I've tested the above powershell code to work fine (locally) so I'll just do it the stupid way this time around as I'm not in a rush.

But I do appreciate your input as always tip hat

i was able to

  1. create a rclone mount as x:
  2. modify modification date of a file x:\backup\BJ_V_H.VSERVER03_G.AMPE01.md5
  3. notice that the date
  4. that would mean you should be able to use your original powershell code.

Via mount you mean? Yea I did try that - and it ran, but nothing seemed to happen.
you didn't have vfs-cache-mode writes on for that test did you? I assumed that wouldn't matter...

rclone.exe mount wasabiwest01:vserver03-bjv.h.vserver03.g.ampe01\ x:

Mmm, tried again - but no luck.
I assume you used some other method of setting the modtime right? I have no clue how powershell functions honestly, so I assumed it's probably just due to winfsp NTFS emulation not being that perfect.

i use doublecommander instead of windows explorer.
it has a way to change file attributes

1 Like

Oh... well since it has a "including subfolders" option that might work then. I'll test that

this also works

"C:\Program Files\FSTouch\fsTouch64.exe" /px:*.* /s /d:"2000/01/01" /t:"00:00:00"

1 Like

Both of these seem to work decently well - if slow - but this isn't something I intend to do often anyway :slight_smile:
Nice solutions!

Place the following two lines in a Windows .bat file, edit the folder paths as appropriate making sure both lines reference the same path. Leave --no-create asis as insurance !
Leave the double-quotes intact. It ensures that paths and file names containing spaces will be handled correctly by the batch file.
You can remove --max-age 1y if it's not appropriate to your requirements.
I've used this batch file many times on many different folders to touch thousands of files.
bn: is my GoogleDrive

rclone lsf -R --files-only --max-age 1y bn:somefolder/somesubfolder/ | sort > entirefolder.txt
for /F "tokens=*" %%A in (entirefolder.txt) do rclone touch --no-create --timestamp "2000-01-01T00:00:01" bn:"somefolder/somesubfolder/%%A"

1 Like

weclome to the forum.
thanks for the suggestion.

1 Like

That looks pretty sweet. Probably both fast and robust, using rclone and being outside of mount as well.
I've already saved it for later use, thanks!
Now I know who to bother when I need help on my batch scripts :stuck_out_tongue:

1 Like