Script to clone a template folder retaing permissions and prompt for new folder name










-1















May I please get your insight?



I have a user group in AD call Contract Admin. I like would this user group to be able to run a script that clones a template folder (retaining permissions) to a new folder and prompt for a new client name.



The folder structure would be as follows:




  • Clients


    • New Folder (template folder) (Permissions: Admins, Contract Admin, Financial Admin)


      • Statements Folder (Permissions: Financial Admin)



End result after script:




  • Clients


    • ABC Company (Permissions: Admins, Contract Admin, Financial Admin)


      • Statements Folder (Permissions: Financial Admin)



Above is an example of the folder structure where New Folder is the template folder which also has a folder inside of it as well. I'd like to have the folders cloned with permissions retained.



I hope this is clear, I apologize if it is not. Thank you so much for your help.



The code I currently have for copying the permissions are as folows:



robocopy /e /copy:DATS "X:Template" "X:New Folder Name"



attrib -h "Template"



This is what I have for cloning the folders but I am lost from here.
Thank you



Solution:
@echo off



set "src=C:UsersXXXDesktoptemplate folder"



set /p "dest=Name of Client?: "



robocopy /e /copy:DATS %src% %dest%




the source can simply be the folder/file name without the full path if both the script and the folder/file to be copied is in the same directory.



/copy: Specifies the file properties to be copied. The following are the valid values for this option:



  • D Data A Attributes

  • T Time stamps S NTFS access control list (ACL)

  • O Owner information

  • U Auditing information

  • The default value for

  • CopyFlags is DAT (data, attributes, and time stamps).









share|improve this question
























  • StackOverFlow was created to ask questions about code you are trying to use. Your question is off topic for this website.

    – Squashman
    Nov 12 '18 at 23:26











  • My sincere apologies, I have added the coding that i started for the batch file.

    – Rooney
    Nov 13 '18 at 0:37











  • I was able to use robocopy to accomplish the task:

    – Rooney
    Nov 14 '18 at 23:35















-1















May I please get your insight?



I have a user group in AD call Contract Admin. I like would this user group to be able to run a script that clones a template folder (retaining permissions) to a new folder and prompt for a new client name.



The folder structure would be as follows:




  • Clients


    • New Folder (template folder) (Permissions: Admins, Contract Admin, Financial Admin)


      • Statements Folder (Permissions: Financial Admin)



End result after script:




  • Clients


    • ABC Company (Permissions: Admins, Contract Admin, Financial Admin)


      • Statements Folder (Permissions: Financial Admin)



Above is an example of the folder structure where New Folder is the template folder which also has a folder inside of it as well. I'd like to have the folders cloned with permissions retained.



I hope this is clear, I apologize if it is not. Thank you so much for your help.



The code I currently have for copying the permissions are as folows:



robocopy /e /copy:DATS "X:Template" "X:New Folder Name"



attrib -h "Template"



This is what I have for cloning the folders but I am lost from here.
Thank you



Solution:
@echo off



set "src=C:UsersXXXDesktoptemplate folder"



set /p "dest=Name of Client?: "



robocopy /e /copy:DATS %src% %dest%




the source can simply be the folder/file name without the full path if both the script and the folder/file to be copied is in the same directory.



/copy: Specifies the file properties to be copied. The following are the valid values for this option:



  • D Data A Attributes

  • T Time stamps S NTFS access control list (ACL)

  • O Owner information

  • U Auditing information

  • The default value for

  • CopyFlags is DAT (data, attributes, and time stamps).









share|improve this question
























  • StackOverFlow was created to ask questions about code you are trying to use. Your question is off topic for this website.

    – Squashman
    Nov 12 '18 at 23:26











  • My sincere apologies, I have added the coding that i started for the batch file.

    – Rooney
    Nov 13 '18 at 0:37











  • I was able to use robocopy to accomplish the task:

    – Rooney
    Nov 14 '18 at 23:35













-1












-1








-1








May I please get your insight?



I have a user group in AD call Contract Admin. I like would this user group to be able to run a script that clones a template folder (retaining permissions) to a new folder and prompt for a new client name.



The folder structure would be as follows:




  • Clients


    • New Folder (template folder) (Permissions: Admins, Contract Admin, Financial Admin)


      • Statements Folder (Permissions: Financial Admin)



End result after script:




  • Clients


    • ABC Company (Permissions: Admins, Contract Admin, Financial Admin)


      • Statements Folder (Permissions: Financial Admin)



Above is an example of the folder structure where New Folder is the template folder which also has a folder inside of it as well. I'd like to have the folders cloned with permissions retained.



I hope this is clear, I apologize if it is not. Thank you so much for your help.



The code I currently have for copying the permissions are as folows:



robocopy /e /copy:DATS "X:Template" "X:New Folder Name"



attrib -h "Template"



This is what I have for cloning the folders but I am lost from here.
Thank you



Solution:
@echo off



set "src=C:UsersXXXDesktoptemplate folder"



set /p "dest=Name of Client?: "



robocopy /e /copy:DATS %src% %dest%




the source can simply be the folder/file name without the full path if both the script and the folder/file to be copied is in the same directory.



/copy: Specifies the file properties to be copied. The following are the valid values for this option:



  • D Data A Attributes

  • T Time stamps S NTFS access control list (ACL)

  • O Owner information

  • U Auditing information

  • The default value for

  • CopyFlags is DAT (data, attributes, and time stamps).









share|improve this question
















May I please get your insight?



I have a user group in AD call Contract Admin. I like would this user group to be able to run a script that clones a template folder (retaining permissions) to a new folder and prompt for a new client name.



The folder structure would be as follows:




  • Clients


    • New Folder (template folder) (Permissions: Admins, Contract Admin, Financial Admin)


      • Statements Folder (Permissions: Financial Admin)



End result after script:




  • Clients


    • ABC Company (Permissions: Admins, Contract Admin, Financial Admin)


      • Statements Folder (Permissions: Financial Admin)



Above is an example of the folder structure where New Folder is the template folder which also has a folder inside of it as well. I'd like to have the folders cloned with permissions retained.



I hope this is clear, I apologize if it is not. Thank you so much for your help.



The code I currently have for copying the permissions are as folows:



robocopy /e /copy:DATS "X:Template" "X:New Folder Name"



attrib -h "Template"



This is what I have for cloning the folders but I am lost from here.
Thank you



Solution:
@echo off



set "src=C:UsersXXXDesktoptemplate folder"



set /p "dest=Name of Client?: "



robocopy /e /copy:DATS %src% %dest%




the source can simply be the folder/file name without the full path if both the script and the folder/file to be copied is in the same directory.



/copy: Specifies the file properties to be copied. The following are the valid values for this option:



  • D Data A Attributes

  • T Time stamps S NTFS access control list (ACL)

  • O Owner information

  • U Auditing information

  • The default value for

  • CopyFlags is DAT (data, attributes, and time stamps).






powershell batch-file command-prompt file-permissions xcopy






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 0:12







Rooney

















asked Nov 12 '18 at 21:33









RooneyRooney

11




11












  • StackOverFlow was created to ask questions about code you are trying to use. Your question is off topic for this website.

    – Squashman
    Nov 12 '18 at 23:26











  • My sincere apologies, I have added the coding that i started for the batch file.

    – Rooney
    Nov 13 '18 at 0:37











  • I was able to use robocopy to accomplish the task:

    – Rooney
    Nov 14 '18 at 23:35

















  • StackOverFlow was created to ask questions about code you are trying to use. Your question is off topic for this website.

    – Squashman
    Nov 12 '18 at 23:26











  • My sincere apologies, I have added the coding that i started for the batch file.

    – Rooney
    Nov 13 '18 at 0:37











  • I was able to use robocopy to accomplish the task:

    – Rooney
    Nov 14 '18 at 23:35
















StackOverFlow was created to ask questions about code you are trying to use. Your question is off topic for this website.

– Squashman
Nov 12 '18 at 23:26





StackOverFlow was created to ask questions about code you are trying to use. Your question is off topic for this website.

– Squashman
Nov 12 '18 at 23:26













My sincere apologies, I have added the coding that i started for the batch file.

– Rooney
Nov 13 '18 at 0:37





My sincere apologies, I have added the coding that i started for the batch file.

– Rooney
Nov 13 '18 at 0:37













I was able to use robocopy to accomplish the task:

– Rooney
Nov 14 '18 at 23:35





I was able to use robocopy to accomplish the task:

– Rooney
Nov 14 '18 at 23:35












1 Answer
1






active

oldest

votes


















0














But this is not a script. It's a robocopy command.



There are many switches robocopy, see its help file for them.



Specifically the mirror (/MIR) a folder tree to a new location.



As for prompting users, there are a few ways to do this. The most direct is Read-Host cmdlet provides. You simply capture that in a variable and pass that as the folder.



$FolderPath = Read-Host 'Enter a folder path.'





share|improve this answer























  • Thank you so much, I will give this a shot. I am new to this scripting and I think i have confused myself with robocopy.

    – Rooney
    Nov 13 '18 at 18:33










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53270420%2fscript-to-clone-a-template-folder-retaing-permissions-and-prompt-for-new-folder%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














But this is not a script. It's a robocopy command.



There are many switches robocopy, see its help file for them.



Specifically the mirror (/MIR) a folder tree to a new location.



As for prompting users, there are a few ways to do this. The most direct is Read-Host cmdlet provides. You simply capture that in a variable and pass that as the folder.



$FolderPath = Read-Host 'Enter a folder path.'





share|improve this answer























  • Thank you so much, I will give this a shot. I am new to this scripting and I think i have confused myself with robocopy.

    – Rooney
    Nov 13 '18 at 18:33















0














But this is not a script. It's a robocopy command.



There are many switches robocopy, see its help file for them.



Specifically the mirror (/MIR) a folder tree to a new location.



As for prompting users, there are a few ways to do this. The most direct is Read-Host cmdlet provides. You simply capture that in a variable and pass that as the folder.



$FolderPath = Read-Host 'Enter a folder path.'





share|improve this answer























  • Thank you so much, I will give this a shot. I am new to this scripting and I think i have confused myself with robocopy.

    – Rooney
    Nov 13 '18 at 18:33













0












0








0







But this is not a script. It's a robocopy command.



There are many switches robocopy, see its help file for them.



Specifically the mirror (/MIR) a folder tree to a new location.



As for prompting users, there are a few ways to do this. The most direct is Read-Host cmdlet provides. You simply capture that in a variable and pass that as the folder.



$FolderPath = Read-Host 'Enter a folder path.'





share|improve this answer













But this is not a script. It's a robocopy command.



There are many switches robocopy, see its help file for them.



Specifically the mirror (/MIR) a folder tree to a new location.



As for prompting users, there are a few ways to do this. The most direct is Read-Host cmdlet provides. You simply capture that in a variable and pass that as the folder.



$FolderPath = Read-Host 'Enter a folder path.'






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 13 '18 at 3:38









postanotepostanote

3,4322410




3,4322410












  • Thank you so much, I will give this a shot. I am new to this scripting and I think i have confused myself with robocopy.

    – Rooney
    Nov 13 '18 at 18:33

















  • Thank you so much, I will give this a shot. I am new to this scripting and I think i have confused myself with robocopy.

    – Rooney
    Nov 13 '18 at 18:33
















Thank you so much, I will give this a shot. I am new to this scripting and I think i have confused myself with robocopy.

– Rooney
Nov 13 '18 at 18:33





Thank you so much, I will give this a shot. I am new to this scripting and I think i have confused myself with robocopy.

– Rooney
Nov 13 '18 at 18:33

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53270420%2fscript-to-clone-a-template-folder-retaing-permissions-and-prompt-for-new-folder%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Use pre created SQLite database for Android project in kotlin

Darth Vader #20

Ondo