-2

lets say i have a dir C:\Project\File\ this directory contains folder1,folder2,folder3 and so on. folder1, folder2 and folder3 have files with extension .txt now i want to copy all the .txt file from all the folder to a folder test in path C:\Users\Use\Desktop\Test

How to do this using batch scripting or using linux command.

2 Answers2

1

as batchfile: for (recursive /r) all .txt files copy the file to <new path>\<name>.<extension> (%%~nxa):

for /r %%a in (*.txt) do @ECHO copy "%%a" "%C:\Users\Use\Desktop\Test\%%~nxa"

if you want to try on command line, use a single % instead of double %%.

Remove @ECHO, if the output is what you want to do.

Stephan
  • 53,940
  • 10
  • 58
  • 91
0

use find with exec:

find C:\\Project\\File -name "*.txt" -exec cp {} C:\\Users\\Use\\Desktop\\Test \;

I'm not sure about the directories because you mention windows style but want find (unix style).

Krzysztof Krasoń
  • 26,515
  • 16
  • 89
  • 115