Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

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

Mar
11
0
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.
 
You have the same files and directory structure under E:\MyDir and F:\MyDir? Sounds to me like a job for FOR /D.
 
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.
 
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.
 

Similar threads

Replies
6
Views
3K
Replies
2
Views
2K
Back
Top