I am struggling to create a batch file that I can use in any folder, which will copy the current folder and all its contents to another location. The objective is to allow me to make very quick backups of any current folder by running the batch file. Batch files are new to me, but programming isn't. Here is my code.
@echo off
title Copy This Directory
:: get current directory
set startdir=%cd%
echo.startdir = %startdir%
:: copy the test folder
xcopy "%startdir%" "F:\Temp Backup\" /s /y
pause
This copies the files and folders that are inside the source folder to the new destination, but I want to copy the folder itself together with its contents. ie if the batch file is in a folder called "FromFolder", I want "FromFolder" to appear as a folder in "F:\Temp Backup\" and all its contents in "F:\Temp Backup\FromFolder". I've found lots of info about copying files, but nothing about copying a single directory. I can copy a single file, but when I use the same code and change the file name to a folder name, it copies the folder's contents and not the folder itself. Could someone let me know what I have missed please.