是否有任何工具或脚本可用于创建数以百万计的文件目录,子目录和子子目录随机在Linux和Windows中。
cwdobuhd1#
mkdir -p folder{1..100000}/folder{1..100000}folder{1..100000}
o8x7eapl2#
谢谢你Kamèl,Dominique,给你的线索我可以实现我想要的。以下示例在4 x 4 x 4 x 4 x 4 = 1024个目录中创建和复制文件在Linux主机上:
# ls -l total 440 -rw-r--r--. 1 root root 86400 Nov 4 07:48 file1 -rw-r--r--. 1 root root 86400 Nov 4 07:48 file2 -rw-r--r--. 1 root root 86400 Nov 4 07:48 file3 -rw-r--r--. 1 root root 86400 Nov 4 07:48 file4 -rw-r--r--. 1 root root 86400 Nov 4 07:49 file5 # while read i ; do echo Creating directories - $i; mkdir -p $i ; done <<< "`echo folder{1..4}/folder{1..4}/folder{1..4}/folder{1..4}/folder{1..4} | sed 's/ /\n/g'`" while read i ; do echo Copying files at $i; cp file1 $i; done <<< "`echo folder{1..4} | sed 's/ /\n/g'`" while read i ; do echo Copying files at $i; cp file2 $i; done <<< "`echo folder{1..4}/folder{1..4} | sed 's/ /\n/g'`" while read i ; do echo Copying files at $i; cp file3 $i; done <<< "`echo folder{1..4}/folder{1..4}/folder{1..4} | sed 's/ /\n/g'`" while read i ; do echo Copying files at $i; cp file4 $i; done <<< "`echo folder{1..4}/folder{1..4}/folder{1..4}/folder{1..4} | sed 's/ /\n/g'`" while read i ; do echo Copying files at $i; cp file5 $i; done <<< "`echo folder{1..4}/folder{1..4}/folder{1..4}/folder{1..4}/folder{1..4} | sed 's/ /\n/g'`" # # [root@DV-S563 tmp]# ls -lR | head -40 .: total 456 -rw-r--r--. 1 root root 86400 Nov 4 07:48 file1 -rw-r--r--. 1 root root 86400 Nov 4 07:48 file2 -rw-r--r--. 1 root root 86400 Nov 4 07:48 file3 -rw-r--r--. 1 root root 86400 Nov 4 07:48 file4 -rw-r--r--. 1 root root 86400 Nov 4 07:49 file5 drwxr-xr-x. 6 root root 4096 Nov 4 07:54 folder1 drwxr-xr-x. 6 root root 4096 Nov 4 07:54 folder2 drwxr-xr-x. 6 root root 4096 Nov 4 07:54 folder3 drwxr-xr-x. 6 root root 4096 Nov 4 07:54 folder4 ./folder1: total 104 -rw-r--r--. 1 root root 86400 Nov 4 07:54 file1 drwxr-xr-x. 6 root root 4096 Nov 4 07:54 folder1 drwxr-xr-x. 6 root root 4096 Nov 4 07:54 folder2 drwxr-xr-x. 6 root root 4096 Nov 4 07:54 folder3 drwxr-xr-x. 6 root root 4096 Nov 4 07:54 folder4 ./folder1/folder1: total 104 -rw-r--r--. 1 root root 86400 Nov 4 07:54 file2 drwxr-xr-x. 6 root root 4096 Nov 4 07:54 folder1 drwxr-xr-x. 6 root root 4096 Nov 4 07:54 folder2 drwxr-xr-x. 6 root root 4096 Nov 4 07:54 folder3 drwxr-xr-x. 6 root root 4096 Nov 4 07:54 folder4 ./folder1/folder1/folder1: total 104 -rw-r--r--. 1 root root 86400 Nov 4 07:54 file3 drwxr-xr-x. 6 root root 4096 Nov 4 07:54 folder1 drwxr-xr-x. 6 root root 4096 Nov 4 07:54 folder2 drwxr-xr-x. 6 root root 4096 Nov 4 07:54 folder3 drwxr-xr-x. 6 root root 4096 Nov 4 07:54 folder4 ./folder1/folder1/folder1/folder1: total 104 -rw-r--r--. 1 root root 86400 Nov 4 07:54 file4 drwxr-xr-x. 2 root root 4096 Nov 4 07:54 folder1 [root@DV-S563 tmp]#
在Windows主机上:
PS C:\Temp> dir Directory: C:\Temp Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 6/19/2022 9:43 AM 2423 file1 -a---- 6/19/2022 9:43 AM 2423 file2 -a---- 6/19/2022 9:43 AM 2423 file3 -a---- 6/19/2022 9:43 AM 2423 file4 -a---- 6/19/2022 9:43 AM 2423 file5 PS C:\Temp> New-Item -Type Directory -Force -Path (1..4 -replace '^', 'folder').ForEach({ 1..4 -replace '^', "$_\folder" }).ForEach({ 1..4 -replace '^', "$_\folder" }).ForEach({ 1..4 -replace '^', "$_\folder" }).ForEach({ 1..4 -replace '^', "$_\folder" }) (1..4 -replace '^', 'folder') | % { Copy-Item file1 -destination $_ } (1..4 -replace '^', 'folder').ForEach({ 1..4 -replace '^', "$_\folder" }) | % { Copy-Item file2 -destination $_ } (1..4 -replace '^', 'folder').ForEach({ 1..4 -replace '^', "$_\folder" }).ForEach({ 1..4 -replace '^', "$_\folder" }) | % { Copy-Item file3 -destination $_ } (1..4 -replace '^', 'folder').ForEach({ 1..4 -replace '^', "$_\folder" }).ForEach({ 1..4 -replace '^', "$_\folder" }).ForEach({ 1..4 -replace '^', "$_\folder" }) | % { Copy-Item file4 -destination $_ } (1..4 -replace '^', 'folder').ForEach({ 1..4 -replace '^', "$_\folder" }).ForEach({ 1..4 -replace '^', "$_\folder" }).ForEach({ 1..4 -replace '^', "$_\folder" }).ForEach({ 1..4 -replace '^', "$_\folder" }) | % { Copy-Item file5 -destination $_ } PS C:\Temp> Get-ChildItem -Recurse Directory: C:\Temp Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 11/4/2022 8:30 PM folder1 d----- 11/4/2022 8:30 PM folder2 d----- 11/4/2022 8:30 PM folder3 d----- 11/4/2022 8:30 PM folder4 -a---- 6/19/2022 9:43 AM 2423 file1 -a---- 6/19/2022 9:43 AM 2423 file2 -a---- 6/19/2022 9:43 AM 2423 file3 -a---- 6/19/2022 9:43 AM 2423 file4 -a---- 6/19/2022 9:43 AM 2423 file5 Directory: C:\Temp\folder1 Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 11/4/2022 8:30 PM folder1 d----- 11/4/2022 8:30 PM folder2 d----- 11/4/2022 8:30 PM folder3 d----- 11/4/2022 8:30 PM folder4 -a---- 6/19/2022 9:43 AM 2423 file1 Directory: C:\Temp\folder1\folder1 Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 11/4/2022 8:30 PM folder1 d----- 11/4/2022 8:30 PM folder2 d----- 11/4/2022 8:30 PM folder3 d----- 11/4/2022 8:30 PM folder4 -a---- 6/19/2022 9:43 AM 2423 file2 Directory: C:\Temp\folder1\folder1\folder1 Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 11/4/2022 8:30 PM folder1 d----- 11/4/2022 8:30 PM folder2 d----- 11/4/2022 8:30 PM folder3 d----- 11/4/2022 8:30 PM folder4 -a---- 6/19/2022 9:43 AM 2423 file3
2条答案
按热度按时间cwdobuhd1#
o8x7eapl2#
谢谢你Kamèl,Dominique,给你的线索
我可以实现我想要的。
以下示例在4 x 4 x 4 x 4 x 4 = 1024个目录中创建和复制文件
在Linux主机上:
在Windows主机上: