如何使用批处理文件从源文件夹中归档文件时,在源文件夹中动态创建子文件夹? [英] How to create subfolders dynamically with in a source folder while archiving files from it using batch file?
问题描述
我想在使用批处理文件脚本从其归档的文件的源文件夹中动态创建子文件夹。目前在将目录设置为能够执行此操作的变量时。
我需要在父文件夹中创建子目录,从中移动文件。
例如:
set SOURCE =E:\ FileStore \A2 \A3
SET DEST =E:\Dest_FileStoe \ Dest_FILESTORE
如果源父文件夹是FileStore,而目标父文件夹是Dest_FileStore,FileStore的子文件夹是A2,A2的子文件夹是A3,如果文件是从A3存档的话在B中,子文件夹A2和A3必须动态创建,因为A3中的文件将使用batfile命令存档。
我尝试过:
I want to create sub folders dynamically with in a source folder of the file archived from it using batch file script. Currently while setting a directory to a variable able to do so.
My need is to create subdirectory with in parent folder from which file is being moved.
For example:
set SOURCE="E:\FileStore\A2\A3"
SET DEST="E:\Dest_FileStoe\Dest_FILESTORE"
If source parent folder is FileStore and Destination Parent Folder is Dest_FileStore and subfolder of FileStore is A2 and subfolder of A2 is A3 and if files are archived from A3 then in B the subfolders A2 and A3 must be created dynamically as the files with in A3 are to be archived using batfile command .
What I have tried:
@ECHO OFF
setlocal enabledelayedexpansion
set SOURCE="E:\FileStore\A2\A3"
SET DEST="E:\Dest_FileStoe\Dest_FILESTORE"
echo %SOURCE% %DEST%
IF NOT EXIST %DEST% mkdir %DEST%
My need is to create subdirectory with in parent folder from which file is being moved.
For example:
set SOURCE="E:\FileStore\A2\A3"
SET DEST="E:\Dest_FileStoe\Dest_FILESTORE"
If source parent folder is FileStore and Destination Parent Folder is Dest_FileStore and subfolder of FileStore is A2 and subfolder of A2 is A3 and if files are archived from A3 then in B the subfolders A2 and A3 must be created dynamically as the files with in A3 are to be archived using batfile command .
推荐答案
观看:如何使用批处理文件一次创建多个文件夹 - YouTube [ ^ ]
使用此 Google搜索:用于创建文件夹和子文件夹的批处理文件 [ ^ ]
Watch this: How to create multiple folders at once using a batch file - YouTube[^]
Found using this Google Search: batch file to create folders and subfolders[^]
这适用于:
This works:
if not exist %DEST%\nul md %DEST%
这篇关于如何使用批处理文件从源文件夹中归档文件时,在源文件夹中动态创建子文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!