简体   繁体   English

想要将所有文件从目录和子目录批量移动到另一个文件夹中

[英]Want to batch move all files from directories and sub directories in to a different folders

I have a Windows directory and in it I have 4000 main sub-directories, in those main sub-directories I have 4000 sub-directories in which I have around 20 files each with syntax File_CreationDate_NUMBER_name.ext . 我有一个Windows目录,在其中有4000个主要子目录,在这些主要子目录中,我有4000个子目录,在其中有大约20个文件,每个文件的语法为File_CreationDate_NUMBER_name.ext

Example: 例:

F:\\DIR\\MAINSUB1\\SUB2\\file_date_number*.rar F:\\ DIR \\ MAINSUB1 \\ SUB2 \\ file_date_number * .rar

F:\\DIR\\MAINSUB1\\SUB3\\file1_date_number*.img F:\\ DIR \\ MAINSUB1 \\ SUB3 \\ file1_date_number * .img

F:\\DIR\\MAINSUB1\\SUB3\\file2_date_*.txt .... till 400 SUB directories then F:\\ DIR \\ MAINSUB1 \\ SUB3 \\ file2_date _ *。txt ....直到400个SUB目录

F:\\DIR\\MAINSUB2\\SUB1\\file2_date_number*.txt F:\\ DIR \\ MAINSUB2 \\ SUB1 \\ file2_date_number * .txt

F:\\DIR\\MAINSUB2\\SUB2\\file2_date_number*.timg F:\\ DIR \\ MAINSUB2 \\ SUB2 \\ file2_date_number * .timg

F:\\DIR\\MAINSUB2\\SUB3\\file2_date_*.html F:\\ DIR \\ MAINSUB2 \\ SUB3 \\ file2_date _ *。html

There are 4000 MainSub directories and in each MainSub directory there are 10000 sub Directories. 有4000个MainSub目录,每个MainSub目录中有10000个子目录。

I want a batch file which copies these files from SUB1, SUB2 ... under MAINSUB directories ... 我想要一个从MAINSUB目录下的SUB1,SUB2 ...复制这些文件的批处理文件...

Example: 例:

D:\\FILES\\MAINSUB1\\all the files from its SUBS into it.. D:\\ FILES \\ MAINSUB1 \\将所有文件从其SUBS放入其中。

D:\\FILES\\MAINSUB2\\all the files from its SUBS into it.. D:\\ FILES \\ MAINSUB2 \\将所有文件从其SUBS放入其中。

.... for all 4000 MAINSUB directories ....对于所有4000个MAINSUB目录

I also want it to give me a prompt to add date in format DDMMYYYY and NUMBER from 0-4. 我还希望它提示我添加DDMMYYYY格式的日期和NUMBER从0-4。

This will handle the move of files (if used from command line, replace %% with %). 这将处理文件的移动(如果从命令行使用,请将%%替换为%)。

for /D %%f in ("d:\files\*") do for /D %%g in ("%%~ff\*") do move "%%~fg\*" "%%~ff"

Not sure where you want the timestamp added. 不确定要在哪里添加时间戳。 Adjust as needed 根据需要调整

EDIT - to adapt to comments 编辑-适应评论

@echo off @回声关闭

setlocal enableextensions

rem from/where to copy
set "source=f:\dir"
set "target=d:\files"

set /p "df=date of files ? :"
set /p "nf=number ? :"

rem ensure final target directory exists
if not exist "%target%" mkdir "%target%"

rem do file copy
for /D %%f in ("f:\files\*") do (
    if not exist "%target%\%%~nxf" mkdir "%target%\%%~nxf" > nul
    for /D %%g in ("%%~ff\*") do (
        copy "%%~fg\*_%df%_%nf%*" "%target%\%%~nxf"
    )
)

endlocal

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 批处理命令将文件从子目录移动到新目录 - Batch Command to Move Files from Sub Directories to New Directory 想要将所有文件从目录批量移动到父目录并删除子目录 - Want to batch move all files from directories into the parent directory and delete the subdirectory 从批处理文件中的子目录中删除文件夹 - Delete folders from child directories in a batch file 使用其他目录中的文件替换子目录中的多个文件 - Replace multiple files in sub directories with file from a different directory 批处理文件以列出其他目录中的所有txt文件 - batch file to list all txt files from other directories 批处理文件:列出目录中的所有文件,打印为.txt并将输出文件放置在所有子目录中 - Batch Files: List all files in a directory, print as .txt and place output file in all sub directories ImageMagick 的批处理命令在 Windows 上转换目录和子目录中的所有文件 - Batch command for ImageMagick to convert all files in a directory and sub-directories on windows 批处理文件以搜索子目录 - batch file to search sub directories 如何使用批处理脚本从当前目录复制文件,而不复制子目录? - How do I copy files from the current directory, but not sub-directories using a batch script? 创建Windows 8批处理文件,以递归方式复制,重命名和保存子目录中的文件 - create windows 8 batch file to copy, rename and save files from sub directories recursively
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM