Touch command — I Need to touch matching files in another directory.

cwc

Mar 9, 2010
11
0
#1
I’ve used the Touch command to copy the dates & times from one file to another, but now I have thousands of files to deal with. I need to copy the dates and times of a directory and its files and subdirectories to matching files and subdirectories in another directory. After studying the documentation on the Touch command, I tried the following —
touch /r "E:MyDir\" /s "F:MyDir\"

It didn’t work — I got a “Can’t find the file "F:MyDir\" message.

Can the Touch command do what I need it to do? If so, what syntax should I use?

Thanks.

BTW, I’m using TC 18.00.16 x64.
 
#3
You are trying to use TOUCH with a file selection similar to what COPY does: with both source and target being directories, COPY takes all files in the source, determines the corresponding file in the target, and performs the copy.

I am afraid with TOUCH you can only:
- TOUCH with the date of a single file:
Code:
TOUCH /r "E:\MyDir\RefFile" /s "F:\MyDir"
- write a loop
Code:
FOR /R %s "E:\MyDir\*" TOUCH /R %s %@REPLACE["E:\MyDir\","F:\MyDir\",%s]
You get the "Can't find the file …" message because TOUCH rejects directories unless you include them through a /A:D option.
 

cwc

Mar 9, 2010
11
0
#4
The FOR command as shown above didn’t work — I got an error message, «Can’t find "E:\MyDir\*"» —
but thanks anyway!

You are trying to use TOUCH with a file selection similar to what COPY does: with both source and target being directories, COPY takes all files in the source, determines the corresponding file in the target, and performs the copy.

I am afraid with TOUCH you can only:
- TOUCH with the date of a single file:
Code:
TOUCH /r "E:\MyDir\RefFile" /s "F:\MyDir"
- write a loop
Code:
FOR /R %s "E:\MyDir\*" TOUCH /R %s %@REPLACE["E:\MyDir\","F:\MyDir\",%s]
You get the "Can't find the file …" message because TOUCH rejects directories unless you include them through a /A:D option.