将所有文件复制到他自己的父母中 [英] Copy all files in his own parent
问题描述
大家好,我需要从一个目录到根目录中提取多个java文件,但是我需要保留第一级.有很多文件和许多不同的文件夹,所以可以提供任何帮助 这是一个示例:
Hi everyone I need to extract multiple java files, from one directory to a root directory, but I need to preserve de first level. there are many files and many different folders, so any help is appreciated Here is an example:
我要做的就是做到
|ROOTDIRECTORY
| |FOLDER1
| | SUBFOLDER
| | | JA.JAVA
| |FOLDER2
| | SUBFOLDER
| | | AAAA.JAVA
| |FOLDER3
| | SUBFOLDER
| | | JAAAA.JAVA
| |FOLDER4
| | SUBFOLDER
| | | |SUBSUBFOLDER
| | | JAV.JAVA
成为
|ROOTDIRECTORY
| |FOLDER1
| | JA.JAVA
| |FOLDER2
| | AAAA.JAVA
| |FOLDER3
| | JAAAA.JAVA
| |FOLDER4
| | JAV.JAVA
在此示例中,我放置了2个级别的子文件夹,但是没有确定数量的子级别
In this example I have put 2 levels of subfolders, but there are an undetermined number of sub-levels
我认为必须有一种快速"进行此操作的方法.有超过500个文件夹和1,000,000个文件.
I think there has to be a way to do this "quickly". There are more than 500 folders and 1,000,000 files.
欢迎任何想法
推荐答案
我可以想象这并不是您要找的东西,但是过去我已经解决了这种情况,并且大多数情况下是在按照以下方式(少矿石):
I can imagine this is not exactly what you're looking for, but I have solved this kind of situations in the past, and mostly I did it in the following way (more ore less):
forfiles /S /M *.Java /C "cmd /C echo @path"
这并没有移动任何东西,它只是显示文件的路径,并具有完整的目录结构.
我给出一个列表,其中包含(根据您的示例)像这样:
This is not moving anything, it's just showing the paths of the files, with complete directory structure.
I gives a list, containing (according to your example) like this:
C:\Folder1\Subfolder\ja.java
...
C:\Folder4\Subfolder\Subsubfolder\jav.java
然后我做两件事:我将该列表保存在某个位置,并使用副本将其变成以下列表:
Then I do two things: I keep this list somewhere, and with the copy, I turn this into the following list:
C:\Folder1\ja.java
...
C:\Folder4\jav.java
我这样做的方法是,用一个简单的"C:\ Folder1 \"替换"C:\ Folder1 \ Subfolder \",用"C:\ Folder4 \"替换"C:\ Folder4 \ Subfolder \ Subsubfolder \"文本编辑器(例如Notepad ++)中的替换命令.
I do this by replacing "C:\Folder1\Subfolder\" by "C:\Folder1\", replacing "C:\Folder4\Subfolder\Subsubfolder\" by "C:\Folder4\", using a simple replacement command in a text editor (like Notepad++).
然后,我使用该文本编辑器的列模式创建以下类型的命令:
Then I use the column mode of that text editor to create the following kind of commands:
mv C:\Folder1\Subfolder\ja.java C:\Folder1\ja.java
....
mv C:\Folder4\Subfolder\Subsubfolder\jav.java C:\Folder4\jav.java
我可以预测您的反应为伙计,那真是la子!",但我看到两个重要的观点:
I can predict your reaction "Man, that's lame!", but I see two important points:
- 根据您的情况,您不希望复制到父文件夹,而是有时复制到父文件夹,这会使整个过程变得非常复杂.
- 我的解决方案为您提供了一种在实际开始执行之前完全验证您所做的一切是否正确的方法(您甚至可以尝试一些行,看看它是否按预期工作).
祝你好运
这篇关于将所有文件复制到他自己的父母中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!