批量替换多个子文件夹中的多个文件(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\*.bat
and 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\ *.batand 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
最满意答案
你有三个地方:
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) ...
-
Java for循环迭代(Java for-loop iteration)[2023-05-28]
这可能对你很有意思。 对于此代码: 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 ... -
TensorFlow:每次迭代训练for-loop慢[重复](TensorFlow: Each iteration in training for-loop slower [duplicate])[2023-08-01]
你有三个地方: 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,CPU):训练循环中的顺序模型吃内存(Keras (TensorFlow, CPU): Training Sequential models in loop eats memory)[2022-12-03]
内存泄漏源于Keras和TensorFlow,它使用单个“默认图”来存储网络结构,随着内部for循环的每次迭代,网络结构的大小都会增加。 调用K.clear_session()可以在迭代之间释放与默认图关联的一些(后端)状态,但需要额外调用tf.reset_default_graph()来清除Python状态。 请注意,可能有更高效的解决方案:因为nn不依赖任何一个循环变量,所以可以在循环外部定义它,并在循环内重用相同的实例。 如果这样做,则不需要清除会话或重置默认图形,并且性能应该提高,因为您可以从迭代之 ... -
1迭代后的循环停止(For-Loop Stopping after 1 Iteration)[2022-02-26]
我仔细阅读了问题陈述 。 我认为你不需要内部循环。 这里的答案是将索引基于列表: 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 ... -
MATLAB:嵌套for循环每次连续迭代都需要更长的时间(MATLAB: Nested for-loop takes longer every successive iteration)[2022-08-22]
因此,当我用以下代码替换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 ... -
不确定for循环迭代?(Unsure about for-loop iteration?)[2022-04-27]
在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 ...