Skip to content
theDXT
  • Home
  • IT
  • Scripts
  • GitHub
  • LinkedIn
  • X (Twitter)
  • Search Icon
copy files and create directories

copy files and create directories

January 19, 2018

I needed to come up with a solution to copy a directory/file to a specific location but I also needed to account for the fact that it might not be created so I needed it to also create the necessary folder structure and if the file existed I needed it to overwrite it.

This is the batch script I came up with

if not exist %appdata%\PROGRAM\settings mkdir %appdata%\PROGRAM\settings
copy "\\SERVER\SHARED\source" %appdata%\PROGRAM\settings /y
Code language: JavaScript (javascript)

Basically what the script is doing is checking C:\Users\USERNAME\AppData\Roaming\PROGRAM\settings to see if it exists if it doesn’t then it will create it. Next the script is copying the contents from the UNC path into the folder.

The way the script is currently written anything in the folder named source will get dumped into the settings folder in Roaming. If you need to copy just a specific file just add the specific file in the copy command and run it. For this solution I just set the script to be a Logon script via a GPO.

Related posts:

VMware Copy Paste Enabler Create Active Directory Central Store geoSCOUT 8.17 Launcher Upgrade geoSCOUT published remote access

IT, Scripts
batch

Post navigation

PREVIOUS
#YYCTube AGM 2017
NEXT
Find files and folders

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

About Me

Daniel Keer

Project Lead, Senior Consultant at Digitally Accurate Inc.

Awards and Certificates
VMware vExpert ⭐⭐⭐
Omnissa Tech Insider ⭐⭐⭐

Consulting

Stuck on something? Reach out to Digitally Accurate Inc. and we can provide expert IT consulting to help you move forward.

  • ESX Regenerate Self-Signed Certificate
  • Veeam Backup & Replication 13 Windows Install
  • Enable Windows 10 Extended Security Updates
  • slmgr.vbs
  • CyberChef
© 2026   Copyright. All Rights Reserved.