[英]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.