Luis Diaz
asked on
VB Script/Batch: create/remove folders based on a config sheet.
Hello experts,
I used the following excellent functions in order to move or copy files and folders based on a config sheet:
Reference proposal:
https://www.experts-exchan ge.com/que stions/289 88927/VBsc ript-Batch -file-copy -files-fol ders-based -on-a-csv- file.html# a41933745
I was wondering if there is a way to use exactly the same process in order to create or delete folders based on a config sheet in which the last param/mode will indicate if the folder that should be created or removed
Example:
The idea is to grill down the creation and the removal.
Example for the creation: if C:\EE, C:\EE\test folders don't exist it should be created when the following line is reported:
C:\EE\test\toto;Create
However for the delete just the last level should be removed
Example for the removal: if C:\EE_Old\Old\titi is reported this means that just titi folder should be removed and no C:\EE_Old\, C:\EE_Old\Old
If the second option for the removal is complicate I will manage this with the whole removal.
I am aware that the best will be to add 4 modes/params
1)Create the full folder even parent folders
2)Create just the last folder reported in that case if the parent folders doesn't exist the action will not be done
3)Remove the full folder even parent folders
4)Remove just the last level of reported folders
Reference log:
-Reference folder doesn’t have the required structure.
-Unable to create folder as it already exist.
-Unable to delete folder as it doesn’t exist
-Unable to delete folder as there is already a file opened or the folder is opened.
If you have questions, please contact me.
I used the following excellent functions in order to move or copy files and folders based on a config sheet:
Reference proposal:
https://www.experts-exchan
I was wondering if there is a way to use exactly the same process in order to create or delete folders based on a config sheet in which the last param/mode will indicate if the folder that should be created or removed
Example:
Reference folder;Mode
C:\EE\test\toto;Create
C:\EE_Old\Old\titi;Delete
The idea is to grill down the creation and the removal.
Example for the creation: if C:\EE, C:\EE\test folders don't exist it should be created when the following line is reported:
C:\EE\test\toto;Create
However for the delete just the last level should be removed
Example for the removal: if C:\EE_Old\Old\titi is reported this means that just titi folder should be removed and no C:\EE_Old\, C:\EE_Old\Old
If the second option for the removal is complicate I will manage this with the whole removal.
I am aware that the best will be to add 4 modes/params
1)Create the full folder even parent folders
2)Create just the last folder reported in that case if the parent folders doesn't exist the action will not be done
3)Remove the full folder even parent folders
4)Remove just the last level of reported folders
Reference log:
-Reference folder doesn’t have the required structure.
-Unable to create folder as it already exist.
-Unable to delete folder as it doesn’t exist
-Unable to delete folder as there is already a file opened or the folder is opened.
If you have questions, please contact me.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
It will create every folder in the path that doesn't exist. So yes, it will create test and toto.
ASKER
Thank you very much for your comment.
I will test it this week.
I will test it this week.
Okay, let me know.
~bp
~bp
ASKER
Hello,
I tested the proposal and it works. Thank you again for your help.
I tested the proposal and it works. Thank you again for your help.
Glad it worked.
ASKER
Sorry for the delay. I will test it as soon as I can.
I have just a question concerning the procedure CreateNesteDir(strPath)
If parent folder doesn't exist it will create the folder or it will skip it?
Example:
I have C:\test\toto
If C:\test doesn't exist it will create the folder C:\test\toto or the procedure requires that C:\test exist?
Thank you again for your help.