首页 \ 问答 \ 批量替换多个子文件夹中的多个文件(Batch replace multiple files in multiple subfolders)

批量替换多个子文件夹中的多个文件(Batch replace multiple files in multiple subfolders)

我刚刚加入stackoverflow,因为你的人很棒。 所以我现在已经批量编写了一年,是的,我知道这和“Gone with the Wind”一样古老,但我别无选择。

我的BATCH问题是这个。 我需要将c:\ folder1 \ *.bat与E:\ Folder4 \ *.bat并仅返回匹配的“.bat”文件。 我可以使用此代码轻松实现此目的....

for / R c:\ folder1 \ %% i in( .bat)如果存在“E:\ Folder4 \ %% ~nxi”(echo %% ~ni)

然后我可以继续按照我喜欢的方式进行操作,其中大部分是备份和替换。 但是,我刚刚遇到了一些有趣的事情。 我现在需要执行相同的操作,但是像这样:

比较c:\ folder1 * .bat中的文件

E:\ Folder4 \ subfolder1 \ * .bat
E:\ Folder4 \ subfolder2 \ * .bat
E:\ Folder4 \ subfolder3 \ * .bat
E:\ Folder4 \ subfolder4 \ * .bat
E:\ Folder4 \ subfolder5 \ * .bat
E:\ Folder4 \ subfolder6 \ * .bat

等等。

我的BATCH问题是如何比较c:\ folder1 * .bat中的内容,看看它是否也在每个E:\ Folder4 \子文件夹中? 一旦完成,我还需要用来自c:\ folder1 * .bat的匹配文件替换E:\ Folder4 \ subfolder中的内容。 我已经用其他语言完成了这项工作,但不知道如何批量处理

谢谢


I just joined stackoverflow because you people are awesome. So I have been batch scripting for a year now, yes I know this is as old as "Gone with the Wind" but I have no choice.

My BATCH issue is this. I need to compare c:\folder1\ *.bat with E:\Folder4\ *.batand only return those ".bat" files which match up. I can easily achieve this with this code....

for /R c:\folder1\ %%i in (.bat) do if exist "E:\Folder4\%%~nxi" (echo %%~ni )

I can then proceed to do as I like which for the most part is backup and replace. However, I just ran into something interesting. I now need to perform the same operation but like so:

Compare files in c:\folder1*.bat with

E:\Folder4\subfolder1\ *.bat
E:\Folder4\subfolder2\ *.bat
E:\Folder4\subfolder3\ *.bat
E:\Folder4\subfolder4\ *.bat
E:\Folder4\subfolder5\ *.bat
E:\Folder4\subfolder6\ *.bat

and so on.

MY BATCH question is how can I compare what's in c:\folder1*.bat and see if its also in each E:\Folder4\subfolder? Once that's done I also need to replace what's in E:\Folder4\subfolder with matching files from c:\folder1*.bat. I've done this in other languages but no clue how to in batch.

Thanks


原文:https://stackoverflow.com/questions/29222615
更新时间:2023-04-05 20:04

最满意答案

你有三个地方:

sess.run(tf.reduce_mean(weights['h1']), ...)

在while循环的每次迭代中,每个追加一个新的tf.reduce_mean()节点到图 ,这会增加开销。 尝试在while循环之外创建它们:

with tf.Graph().as_default():
  ...
  m1 = tf.reduce_mean(weights['h1'])

while batch_iter < batch_size:
  ...
  line_out = ",," + str(sess.run(m1, feed_dict={x: train_features, y_: train_labels}))

The three places where you have:

sess.run(tf.reduce_mean(weights['h1']), ...)

each append a new tf.reduce_mean() node to the graph at each iteration of the while loop, which adds overhead. Try to create them outside of the while loop:

with tf.Graph().as_default():
  ...
  m1 = tf.reduce_mean(weights['h1'])

while batch_iter < batch_size:
  ...
  line_out = ",," + str(sess.run(m1, feed_dict={x: train_features, y_: train_labels}))

相关问答

更多
  • 如果你看到,语法是, for ( declaration expression1opt ; expression2opt ) statement 我们将其与一般性陈述进行比较 for (int i = 0; i < 10; i++) printf("%d \t", i); 这里, int i = 0; 表示declaration [包括; ] i < 10表示expression1opt [可选] ; 根据语法要求; [必须,如语法中所述] i++是expression2opt [可选] print ...
  • 查看关于在c中进行滚动中位数的这个问题的答案。 我已经成功地将它变成了mex函数,它比ordfilt2更快。 做一个最大化需要做一些工作,但我确信这是可能的。 在C - Turlach实施中滚动中位数 Check out the answer to this question about doing a rolling median in c. I've successfully made it into a mex function and it is way faster than even ordfi ...
  • 发生这种情况是因为onload回调函数是异步触发的,因此代码已经结束。 那时info具有在最后一次迭代中分配给它的字符串。 只有这样才会触发onload事件,导致GetThumbnail的不同调用,所有这些调用都会看到相同的info值。 而是将info的值绑定到回调函数,如下所示: reader.onload = GetThumbnail.bind(null, info); ...并在GetThumbnail函数中为它定义相应的参数: function GetThumbnail(info, e) ...
  • 这可能对你很有意思。 对于此代码: class Foo { public static void main(String args[]) { final String str = "1-2-3"; for (int idx = 0; idx < str.split("\\D").length; idx++) { } } } 字节码是: Compiled from "Foo.java" class Foo { Foo(); Code: 0: alo ...
  • 你有三个地方: sess.run(tf.reduce_mean(weights['h1']), ...) 在while循环的每次迭代中,每个追加一个新的tf.reduce_mean()节点到图中 ,这会增加开销。 尝试在while循环之外创建它们: with tf.Graph().as_default(): ... m1 = tf.reduce_mean(weights['h1']) while batch_iter < batch_size: ... line_out = ",," + ...
  • 存在明显的风险,每次完成外部循环的执行时,内部循环的执行次数将增加。 当i为0时,内循环仅执行一次,但当i为100时,将执行101次。 这可以解释你的观察结果,还是你的意思是内循环本身的每次执行都会随着时间的推移变慢? At the risk of stating the obvious, the number of executions of the inner loop will grow each time you complete an execution of the outer loop. Wh ...
  • 内存泄漏源于Keras和TensorFlow,它使用单个“默认图”来存储网络结构,随着内部for循环的每次迭代,网络结构的大小都会增加。 调用K.clear_session()可以在迭代之间释放与默认图关联的一些(后端)状态,但需要额外调用tf.reset_default_graph()来清除Python状态。 请注意,可能有更高效的解决方案:因为nn不依赖任何一个循环变量,所以可以在循环外部定义它,并在循环内重用相同的实例。 如果这样做,则不需要清除会话或重置默认图形,并且性能应该提高,因为您可以从迭代之 ...
  • 我仔细阅读了问题陈述 。 我认为你不需要内部循环。 这里的答案是将索引基于列表: Public Function GetProductDemand() As SortedList(Of String, Integer) Dim prodDemand As New SortedList(Of String, Integer) For i = 0 To products.Length - 1 For j As Integer = 0 To years.Length - 1 ...
  • 因此,当我用以下代码替换if语句时,问题基本上消失了: if mod(i,1e4) == 0 % only for demonstration, not in final script fprintf(1,'time for last 10000 iterations: %f \n',toc); tic; end 我认为对toc的操作可能会导致问题 So, the problem gets largely eliminated when I replace the if statement wit ...
  • 在j += j++你实际上是在做 j = j + j++; 所以对于j=0你会得到 j = 0 + j++ 并且由于j++将在返回其值后递增j ,您将获得 j = 0 + 0; 现在,在j++ j之后将等于1但是,在计算0+0 ,它将返回0并且将打印该值。 In j += j++ you are actually doing j = j + j++; so for j=0 you will get j = 0 + j++ and since j++ will increment j after r ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。