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

cwc

Mar 9, 2010
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 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
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
Thread starter Title Forum Replies Date
Dick Johnson Touch command is off by 1 hour Support 10
Dick Johnson Question about the Touch command Support 0
Frank Abel Cancio Bello How to? specified milliseconds with the touch command? Support 0
vefatica Error message from TOUCH Support 2
fpefpe Documentation touch and /r Support 1
fpefpe Documentation touch Support 6
fpefpe touch - date format Support 2
fpefpe Documentation Touch Support 2
nickles WAD touch with reference file Support 5
vefatica WAD TOUCH /R[acw]? Support 8
JohnQSmith Help file for TOUCH Support 0
MikeBaas TOUCH (V13.04.55) Support 3
J touch Support 3
H touch sensitive to order of options Support 2
C touch /c one;two creates only two Support 3
wadeb question about touch /s Support 2
E TOUCH and DST Support 3
Stefano Piccardi TOUCH a directory? Support 3
Stefano Piccardi TOUCH question Support 3
T VIEW only works from command line Support 13
rconn News Take Command / TCC / CMDebug / TCC-RT v28 Released Support 0
T Take Command 28: Lua reports version 5.4.0 (5.4.3 expected) Support 0
Jay Sage WAD Possible Bug With OPTION Command With @FILE Support 5
rconn News Take Command / TCC / CMDebug / TCC-RT 27.01.24 uploaded Support 0
J Take command does not start on Windows 10 Support 3
vefatica `Back quotes` - command line vs. batch file Support 5
Jay Sage WAD Failure of Alias Command with /Z Option Support 14
Phileosophos Is there any way to open the Take Command options dialog from the command line? Support 8
Phileosophos Command-line Editing Shortkeys That Fail Support 6
fpefpe How to? free (internal) command Support 0
rconn News Take Command / TCC / CMDebug / TCC-RT 27.01.23 uploaded Support 0
T How to? retain command history across reboot? Support 6
rconn News Take Command / TCC / CMDebug / TCC-RT v27.01 Build 22 Uploaded Support 0
Jay Sage Bug With Flow Control and/or Command Grouping Support 2
GermanDirk How to? EVENTLOG Command with simple User Rights not functional Support 4
Jay Sage Take Command Is Too Fast! Support 4
Jay Sage Comparison of IF with Command Group and IFF Support 6
D Open Windows 10 Photos app from command line Support 11
rconn News Take Command / TCC / CMDebug / TCC-RT 27.0.21 uploaded Support 0
rconn News Take Command / TCC / CMDebug / TCC-RT 27.0.20 uploaded Support 0
U Can not get/start Take Command gui Support 1
rconn News Take Command / TCC / CMDebug / TCC-RT 27.0.19 Support 0
S Increasing Font Point Size in Command Tabs Support 2
mfarah Fixed The DATE command produces the wrong error message. Support 1
vefatica Command name mix-up Support 3
FreezerBurnt "Missing SETLOCAL" when initializing Visual Studio Command Prompt. Support 9
E How to? Closing desktop created by DESKTOP command Support 10
rconn News Take Command / TCC / CMDebug / TCC-RT v27.0.18 Support 0
K Take Command fox XP? Support 7
Joe Caverly Documentation Replace internal command with LIBRARY command Support 0

Similar threads