Click here to Skip to main content
15,888,025 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
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  .
Posted
Updated 17-Sep-17 18:27pm
v2
Comments
Graeme_Grant 18-Sep-17 0:56am    
I can see that you have updated your question. The new information is not very clear.

I gather that this is runing on a Windows-based system. So why do you want to use a non-Windows MS-DOS batch file? Why not create a small app, in your favourite language, to do this? Soon, Microsoft may drop support for MS-DOS batch files and then your task will no longer function. Alternatively, use PowerShell[^] scripts instead of Batch files as they're the replacement offering a lot more!

I say this as you have lost 3 days already trying to do, and get help with, to complete the task. Batch files are very limited, and can get overly complex (difficult to modify, debug, and maintain) very quickly, just like in your question in which you struggle to describe - that should be a warning in itself to you.

UPDATE: Not advisable to repost the question with a newly created account - this won't get help quicker, only deeper in trouble and possibly banned. We are volunteers and freely give our time to help others like yourself. Remember to be respectful when using this service:
* Code Project Quick Answers FAQ[^]
* Some guidelines for posting questions in the forums[^]
[no name] 18-Sep-17 1:25am    
Will take care of not re posting. why I asked for bat file since it is the need of the client for file archival.

The base case asked is whether it is possible to create sub directory with in a source parent directory from which file is archived to destination parent directory dynamically using bat file.

 
Share this answer
 
v2
Comments
[no name] 14-Sep-17 9:10am    
I want to get the sub folder of the parent folder set for Archival and create dynamically in the destination folder.
This works:
if not exist %DEST%\nul md %DEST%
 
Share this answer
 
Comments
[no name] 18-Sep-17 0:12am    
As per above subdirectory is created if mentioned in Destination Folder.
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 and files with in A3 are to be archived using batfile command .

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900