如何一个文件夹复制到文件夹的所有其他子文件夹? [英] How to copy one folder to all other subfolders of a folder?

查看:215
本文介绍了如何一个文件夹复制到文件夹的所有其他子文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要文件夹复制图片到一个文件夹中的所有其他文件夹。

I want to copy folder IMAGE to all other folders in a folder.

文件夹结构是:


  • 测试文件夹

    • FirstSubFolder

    • 图片

    • OneMoreSubFolder

    • 测试文件夹1

    • TestFolder2

    结果应该是:


    • 测试文件夹

      • FirstSubFolder

        • 图片

        • Test folder
          • FirstSubFolder
            • IMAGE

            • 图片

            • IMAGE

            • 图片

            • IMAGE

            • 图片

            • IMAGE

            哪些命令,我​​需要一个批处理脚本做这个文件夹复制任务?

            Which commands do I need in a batch script to do this folder copying task?

            推荐答案

            通过测试文件夹是当前目录,使用下面的批处理code:

            With Test folder being the current directory use following batch code:

            @echo off
            for /D %%D in (*) do (
                if /I not "%%D" == "IMAGE" (
                    xcopy "IMAGE\*" "%%D\IMAGE\" /C /E /H /I /K /Q /R /Y >nul
                )
            )
            

            或者,如果只是在映像的文件和子文件夹应该被复制到测试文件夹的其他所有子文件夹,使用这code:

            Or if just the files and subfolders in IMAGE should be copied to all other subfolders of Test folder, use this code:

            @echo off
            for /D %%D in (*) do (
                if /I not "%%D" == "IMAGE" (
                    xcopy "IMAGE\*" "%%D\" /C /E /H /I /K /Q /R /Y >nul
                )
            )
            

            有关理解使用的命令以及它们如何工作,打开命令提示符窗口中,执行有下面的命令,并阅读完全针对每个命令显示的所有帮助页面非常谨慎。

            For understanding the used commands and how they work, open a command prompt window, execute there the following commands, and read entirely all help pages displayed for each command very carefully.


            • 回声/?

            • 为/?

            • 如果/?

            • XCOPY /?

            • echo /?
            • for /?
            • if /?
            • xcopy /?

            这篇关于如何一个文件夹复制到文件夹的所有其他子文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆