I have used robocopy and a script to copy files from various resources. I now want to have my script automatically burn the files I copied to a cd. I'm looking for a command. I have tried xcopy but I keep getting an invalid drive error when trying to copy to the cd burner drive. I'm thinking I should be able to do this with a command or two, instead of having the script open up windows explorer, change to the folder, etc.
Windows – How to burn a cd (files not iso) from the command line in Windows 7
cd-burningscriptwindows 7
Related Solutions
Could somebody help me with my syntax?
There are several problems with your batch file:
The options to xcopy go after the source and destination
XCOPY source [destination] [options]
Your
SET dateNtime...
command is broken.It contains spaces and trailing spaces.
Using
%date%
to provide a solution is dependent on the OS Locale, Regional, and Language settings.Rather than try and fix your code I've provided working code using
wmic
(see getdate)This code works independently of OS Locale, Language or the user's chosen date format (Control Panel/Regional) and it is very easy to change the output format.
The following batch file fixes both of these issues:
@echo off
setlocal enableDelayedExpansion
set/P Drive= Enter destination drive (with colon):
::
set BACKUPCMD=xcopy
SET BACKUPOPTIONS=/S /D /I /Y /Q /C /T
::
rem get date independently of OS Locale, Language or the user's chosen date format (Control Panel/Regional).
rem use findstr to strip blank lines from wmic output
for /f "usebackq skip=1 tokens=1-6" %%g in (`wmic Path Win32_LocalTime Get Day^,Hour^,Minute^,Month^,Second^,Year ^| findstr /r /v "^$"`) do (
set _day=00%%g
set _hours=00%%h
set _minutes=00%%i
set _month=00%%j
set _seconds=00%%k
set _year=%%l
)
rem pad with leading zeros
set _month=%_month:~-2%
set _day=%_day:~-2%
set _hh=%_hours:~-2%
set _mm=%_minutes:~-2%
set _ss=%_seconds:~-2%
rem adjust _date as appropriate for your requirements
set _date=%_year%%_month%%_day%%_hh%%_mm%%_ss%
::
set directory=TEST
set source=%directory%
set destination=%Drive%\ARCHIVE_%_date%\%directory%
echo %BACKUPCMD% "C:\%source%\*.*" "%destination%" %BACKUPOPTIONS%
Notes:
- I'm not sure from your question exactly what date format you are looking for.
- Change
set _date=%_year%%_month%%_day%%_hh%%_mm%%_ss%
as appropriate to get your required date format. - Remove the last
echo
when you are happy with thexcopy
command.
Further Reading
- An A-Z Index of the Windows CMD command line - An excellent reference for all things Windows cmd line related.
- for /f - Loop command against the results of another command.
- getdate - Display the date and time independent of OS Locale, Language or the users chosen date format (Control Panel/Regional).
- wmic - Windows Management Instrumentation Command.
- xcopy - Copy files and/or directory trees to another folder.
I can move one file to the folder at a time, but I can't seem to move both
I keep getting
The syntax of the command is incorrect
. even if I remove the comma in between the two files.
The source must be a single file, a directory, or a wildcard expression. None of these apply in your case, where you are specifying two files.
The syntax of the move
command is:
Syntax
MOVE [options] [Source] [Target]
Key
source : The path and filename of the file(s) to move. target : The path and filename to move file(s) to. options: /Y Suppress confirmation prompt, when overwriting files. /-Y Enable confirmation prompt, when overwriting files.
Both Source and Target can be either a folder or a single file.
The source can include wildcards (but not the destination).
Source move
Assuming that your source directory contains only the 2 ipynb
listed in the question you can use the following command:
move *.ipynb "Scraping projects"
Further Reading
- An A-Z Index of the Windows CMD command line
- move - Move a file from one folder to another.
- wildcards
Best Answer
Well, the Windows 2003 Resource Kit had two CLI programs to burn ISO images. I once saw a program using these in order to burn a folder, but afaik it did not work with files.
A good program designed for burning via command line is CreateCD.
This should do the trick, and probably is easier than getting cdrdao or cdrtools to work. Although they also have a good reputation ;-).
Additionally, popular burning freeware like CDBurnerXP, ImgBurn support burning from a command line.
I also use ImgBurn.