I need to copy all files which sit from one subfolder to another location. The issue is that I do not know how many subfolder levels under one known folder (efg) downtwards to this final subfolder, which shall have files with extension .S3S, this final subfolder name can vary depend on different naming convertion...

For examples, I have some files sit in C:\abc\efg\...\1.S3S
C:\abc\efg\...\2.S3S
C:\abc\efg\...\3.S3S
C:\abc\efg\...\4.S3S
C:\abc\efg\...\5.S3S
I need to copy to C:\target folder\

A few more questions to you:
1) Will the file be found if the file extension was stripped from the file name?
2) What is the difference between the content of %%G in the FOR /F loop and the content of %%G in the FOR /R loop?

A few more questions to you:
1) Will the file be found if the file extension was stripped from the file name?
2) What is the difference between the content of %%G in the FOR /F loop and the content of %%G in the FOR /R loop?

Steffen

FOR /F - Loop through items in a text file
FOR /R - Loop through files (recurse subfolders)

Not in your case. And you didn't answer my question of what you'll find in %%G. (hint: ECHO %%G helps to figure it out)

FWIW FOR /F processes streams. That can be file streams besides of the standard output stream or string streams. In your example the standard output stream of the DIR command will be processed. No text file is involved.

Not in your case. And you didn't answer my question of what you'll find in %%G. (hint: ECHO %%G helps to figure it out)

FWIW FOR /F processes streams. That can be file streams besides of the standard output stream or string streams. In your example the standard output stream of the DIR command will be processed. No text file is involved.

Steffen

You are right, there is another one for
FOR /F - Loop through the output of a command
Thanks a lot!