Windows命令/命令到FIND文件,并将其复制到启动批处理文件的特定位置或目录 [英] Windows command/commands to FIND file and COPY it to certain location or directory where batch file was launched from
问题描述
所以,我开始这样:
copy | dir / s / b |找到myFileC:\Destination
但问题是目标不在此命令。它只能看到命令的第一部分,直到C:\ Destination。
有没有办法可以搜索文件并复制?
我也试过这样:
SET source = dir / s / b |找到myFile
SET目标=%CD%
复制%file%%destination%
$ b b
但不起作用。
在某些时候甚至尝试设置一个指向当前目录的变量(%CD
PS:
我正在寻找一个解决方案,将工作没有安装任何新的计算机上,这就是为什么我在想批量文件。我想我可以这样做VBscript但我不确定。
dir / s / b |如果有人认为这是一个更好的选择, for / f%i in('find'myFile'')do copy%i.\
。任何人都知道如何使用相同的行将相同的命名文件复制到具有新名称的目录。
示例:
文件名为:text.txt
上述命令行搜索许多文件夹,并复制所有实例,如下所示:
1text.txt,2text.txt,3text。 txt
So, I have started with this:
copy | dir /s /b | find "myFile" C:\Destination
but the problem is that the destination is not visible in this command. It only sees the first part of the command up until C:\Destination.
Is there a way I can search for a file and copy it?
I have also tried this:
SET source = dir /s /b | find "myFile"
SET destination = %CD%
copy %file% %destination%
but it doesn't work.
At some point even trying to set a variable that points to the current directory (%CD%
) doesn't work.
Thanks in advance!
PS: I'm looking for a solution that would work without installing anything new on the computer, that's why I'm thinking of batch files.
I think I could do this with VBscript but I'm not sure. If anyone thinks it's a better option please post that answer too.
dir/s/b|for /f %i in ('find "myFile"') do copy "%i" .\
Works very nicely for me. Anyone know how to use the same line to copy same named files to a directory with new names. Example: file name is: text.txt the above command line searches many folders and copies all instances found like below: 1text.txt, 2text.txt, 3text.txt
这篇关于Windows命令/命令到FIND文件,并将其复制到启动批处理文件的特定位置或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!