本文介绍了如何使用Windows cmd命令将所有文件移动到父文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如:



我有




  • C:\ Folder \Subfolder1\SubfolderA\file1.pdf

  • C:\Folder\Subfolder1\SubfolderB\file2.pdf

  • C :\Folder\Subfolder1\Subfolderc\file3.pdf



我只想有这个路径:




  • C:\Folder\Subfolder1\SubfolderA

  • C:\Folder\Subfolder1\\ \\ SubfolderB

  • C:\Folder\Subfolder1\file1.pdf
  • li>
  • C:\Folder\Subfolder1\file2.pdf

  • C:\Folder\Subfolder1\file3.pdf



我使用Windows 7,并在CMD中尝试了不同的命令,如:



code> Move C:\Folder\Subfolder1\SubfolderA\ *。* C:\Folder\Subfolder1\SubfolderA



我花了将近一天时间探索不同的解决方案,因为我工作了大约数千个文件;


b p $ p> for / d%A in(D:\Shawu\Access\Main\ *)do @(pushd%A& %B在(*)do @move / y%B \ *%A2> nul)& popd)

小心具有重复名称的文件。它将覆盖。我建议你先试用一些测试文件,看看你是否得到了想要的结果。



谢谢!


For Example:

I have

  • C:\Folder\Subfolder1\SubfolderA\file1.pdf
  • C:\Folder\Subfolder1\SubfolderB\file2.pdf
  • C:\Folder\Subfolder1\Subfolderc\file3.pdf

And I just want to have this path:

  • C:\Folder\Subfolder1\SubfolderA
  • C:\Folder\Subfolder1\SubfolderB
  • C:\Folder\Subfolder1\Subfolderc
  • C:\Folder\Subfolder1\file1.pdf
  • C:\Folder\Subfolder1\file2.pdf
  • C:\Folder\Subfolder1\file3.pdf

I am using Windows 7, and tried different commands in CMD, like:

Move C:\Folder\Subfolder1\SubfolderA\*.* C:\Folder\Subfolder1\SubfolderA

I spent almost a day exploring different solutions to do this since I am working around thousands of files; and so impractical to do this manually.

解决方案

Try this command

for /d %A in ("D:\Shawu\Access\Main\*") do @(pushd "%A"&(for /r /d %B in (*) do @move /y "%B\*" "%A" 2>nul)&popd)

Be careful of files with duplicate names. It will overwrite. I would recommend you to try first with some test file to see whether you get the desired results.

Thanks!

这篇关于如何使用Windows cmd命令将所有文件移动到父文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 05:02