Copying files from a CD to hard drive, then run Java - cmd

I'm trying to have a bat inside the CD that will copy the Folder 'src' to desktop.
How can I get the files to copy to a directory, like the desktop, and then run the Java command?
xcopy /s/e /y c:\Desktop\Game \src
cd c:\Desktop\Game
java com/brackeen/javagamebook/tilegame/GameManager

#SET $source=*Your source path*
#SET $destination=*Your destination path*
#xcopy "%$source%" "%$destination%" /E /I /R /Y /Z
#IF ERRORLEVEL 1 ECHO Copy failed. && GOTO :EOF
#CD /D "%$destination%"
#*Start your java command*
Xcopy parameters used :
/E Copy folders and subfolders, including Empty folders
/I Assume the destination is a folder when the destination does not exist
/R Overwrite read-only files.
/Y Suppress prompt to confirm overwriting a file.
/Z Copy files in restartable mode.
More at SS64.com

Related

xcopy batch folder tree

S:
cd \newclients
xcopy "s:\clients\*\MER" . /s /d
pause
This is my batch file. In my folder tree we have clients then names folders then MER folder. I want to be able to search the directory for the MER folder and copy that folder along with the client name before it. Is there a way to do this with batch files?
Using if exist should do the thing.
pushd "s:\newclients"
for /f "delims=" %%f in ('dir /b /ad "s:\clients\*"') do (
if exist "s:\clients\%%f\MER\nul" ( xcopy "s:\clients\%%f\MER" "s:\newclients" /s /d )
)
popd
pause
Note: Add a slash if it's to check folder ie. if exist "s:\clients\%%f\MER\" ... or if exist "s:\clients\%%f\MER\nul" ...
To suppress prompt about destination file/folder add /I in xcopy :
/I If in doubt always assume the destination is a folder
e.g. when the destination does not exist.
https://stackoverflow.com/a/33445866/

Why isn't this xcopy command not working?

I am trying to run a simple xcopy batch script but I am facing some difficoulties.
Here is the script
SET SRC=C:\FOLDER1\FOLDER2
SET DEST=V:\FOLDER1
FOR /D %%d in (%SRC%\*) do xcopy /S /I /y /exclude:%SRC%\exclude.txt %%d V:\FOLDER1\%%~nxd
Basically this script should copy some of the subfolders of C:\FOLDER1\FOLDER2 (excluded.txt contains a list of directories to exclude) and its content to the destination. However when I run the scripts, altough no errors are thrown, NO FILES OR FOLDERS get copied. What am I doing wrong?
Interestingly if I run the following script INSIDE FOLDER2, everything procedes as expected.
FOR /D %%A in (*) DO xcopy /S /I /y /exclude:exclude.txt %%A V:\FOLDER1\%%A
xcopy "C:\FOLDER1\FOLDER2" "V:\FOLDER1" /e /i /y
You mention nothing about excluding any folders.

Copy only directories from a command prompt

I want to copy only directories (it's files and sub directories) within the current directory from a command prompt.
I've already copied all the files in the current directory using this command.
copy * d:\copyfolder
I've tried these for individual folders. To copy a folder:
XCOPY C:\utils D:\Backup\utils /i
To copy a folder including all subfolders.
XCOPY C:\utils* D:\Backup\utils /s /i
But couldn't find a way to copy only directories.
From the command line this should work to copy all folders with subdirectories and files:
for /d %a in (*) do xcopy "%a\*.*" "d:\copyfolder\%a\" /s/h/e/k/f/c
I've tried these for individual folders.
To copy a folder:
XCOPY C:\utils D:\Backup\utils /i
To copy a folder including all subfolders.
XCOPY C:\utils\* D:\Backup\utils /s /i
But this command can help, not overwriting any files.
XCOPY C:\utils\* D:\Backup\utils /s /i /d

Script: How to copy/move folders dynamically in Windows using commands

I am having a source folder which has folders (say A,B,C) that i should copy to my destination folder, But while copying if my destination folder has a folder say A, then that folder should not be copied, other two folders should be copied to the destination folder.
I myself found a solution for this.
I use XCOPY with the following parameters: /D /Y /R /H /s /i.
E.g.:
xcopy source destination /D /Y /R /H /s /i

How can I recursively copy files of a specific pattern into a single flat folder on Windows?

I need to copy a set of DLL and PDB files from a set of folders recursively into another folder. I don't want to recreate the folder hierarchy in the target folder.
I want to use built in Windows tools, e.g. DOS commands.
mkdir targetDir
for /r %x in (*.dll, *pdb) do copy "%x" targetDir\
Use /Y at the end of the above command if you are copying multiple files and don't want to keep answering "Yes".
command XCOPY
example of copying folder recursively:
mkdir DestFolder
xcopy SrcFolder DestFolder /E
(as stated below in the comment following WIKI that command was made available since DOS 3.2)
Make sure that you have the quotes right if you have spaces in your path.
This is my postbuild event for my TFS build server (that is why there is "%%"). I needed all the test files to be copied over.
if not exist "$(TargetDir)..\SingleFolderOutput" mkdir -p "$(TargetDir)..\SingleFolderOutput"
for /r **%%x** in (*.dll, *.pdb, *.xml, *.xaml, *.exe, *.exe.config) do xcopy **"%%x"** "$(TargetDir)..\SingleFolderOutput" /Y
For gathering PBD files I end up with this:
cmd /q /c for /R "<your_source_folder>" %f in (*.pdb) do xcopy "%f" "<your_destination_folder>" /I /Y
Note: must be two percent chars, if you use for /r from cmd-file:
for /r %%x in (*.dll, *pdb) do copy "%%x" targetDir\
#echo off
if %1'==' goto usage
if %2'==' goto usage
if %3'==' goto usage
for /D %%F in (%1\*) do xcopy %%F\%2 %3 /D /Y
for /D %%F in (%1\*.) do call TreeCopy %%F %2 %3
goto end
:usage
#echo Usage: TreeCopy [Source folder] [Search pattern] [Destination folder]
#echo Example: TreeCopy C:\Project\UDI *.xsd C:\Project\UDI\SOA\Deploy\Metadata
:end
I'm not aware of any command line tools that do this directly, but you could create a batch script to loop through sub folders, and copy the files you need.
However you may end up with files with duplicate filenames if you place them all in the same folder.

Resources