Bactch script to copy every filese and subFolder to the specific distination


Recently, I have working on the Android project we work with git (bitbucket). The problems is the git repository contain the Eclipse configuration but I prefer to use Android Studio (IntelliJ) to work. So It's quite hard to commit the project built from IntelliJ which has different folder structure from Eclipse.

The solution is using the script that will move every files and subFolder from IntelliJ project to eclipse project. Then run this script every time I run the project. After a searched here is the results.

D:
robocopy D:\androidWorkspace\AndroidIntelliJ\secretProject\src\main\java\com\umitems\mtd D:\androidWorkspace\EclipseSecretProject\src\com\umitems\mtd /E

robocopy D:\androidWorkspace\AndroidIntelliJ\secretProject\src\main\res D:\androidWorkspace\EclipseSecretProject\res /E

copy D:\androidWorkspace\AndroidIntelliJ\secretProject\src\main\AndroidManifest.xml D:\androidWorkspace\EclipseSecretProject\AndroidManifest.xml /Y

I save this code in file moveFiles2Eclipse.bat and call this file as an exerternal tool when I run the project in AndroidStudio.

Note:

copy probably copy single specific file

COPY [/Y|-Y] [/A][/B] [d:][path]filename [/A][/B] [d:][path][filename] [/V]

/Y - Causes COPY to replace existing files.

robocopy will copy copy every filese and subFolder to the specific distination

ROBOCOPY <source> <destination> [file…] [options]

OptionDescription
/s
Copies subdirectories. Note that this option excludes empty directories.
/e
Copies subdirectories. Note that this option includes empty directories. For additional information, see Remarks.
/lev:<N>
Copies only the top N levels of the source directory tree.
/z
Copies files in Restart mode.
/b
Copies files in Backup mode.
/zb
Uses Restart mode. If access is denied, this option uses Backup mode.
/efsraw
Copies all encrypted files in EFS RAW mode.
/copy:<CopyFlags>
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).
/dcopy:T
Copies directory time stamps.
/sec
Copies files with security (equivalent to /copy:DAT).
/copyall
Copies all file information (equivalent to /copy:DATSOU).
/nocopy
Copies no file information (useful with /purge).
/secfix
Fixes file security on all files, even skipped ones.
/timfix
Fixes file times on all files, even skipped ones.
/purge
Deletes destination files and directories that no longer exist in the source. For additional information, see Remarks.
/mir
Mirrors a directory tree (equivalent to /e plus /purge). For additional information, see Remarks.
/mov
Moves files, and deletes them from the source after they are copied.
/move
Moves files and directories, and deletes them from the source after they are copied.
/a+:[RASHCNET]
Adds the specified attributes to copied files.
/a-:[RASHCNET]
Removes the specified attributes from copied files.
/create
Creates a directory tree and zero-length files only.
/fat
Creates destination files by using 8.3 character-length FAT file names only.
/256
Turns off support for very long paths (longer than 256 characters).
/mon:<N>
Monitors the source, and runs again when more than N changes are detected.
/mot:<M>
Monitors source, and runs again in M minutes if changes are detected.
/MT[:N]
Creates multi-threaded copies with N threads. N must be an integer between 1 and 128. The default value for N is 8.
The /MT parameter cannot be used with the /IPG and /EFSRAW parameters.
Redirect output using /LOG option for better performance.
noteNote
The /MT parameter applies to Windows Server 2008 R2 and Windows 7.
/rh:hhmm-hhmm
Specifies run times when new copies may be started.
/pf
Checks run times on a per-file (not per-pass) basis.
/ipg:n
Specifies the inter-packet gap to free bandwidth on slow lines.
/sl
Copies the symbolic link instead of the target.

More option for copy

/-Y - Displays a confirmation prompt before copying over existing files.

/A - Used to copy ASCII files. Applies to the filename preceding it and to all following filenames. Files will be copied until an end-of-file mark is encountered in the file being copied. If an end-of-file mark is encountered in the file, the rest of the file is not copied. DOS will append an end-of-file mark at the end of the copied file.

/B - Used to copy binary files. Applies to the filename preceding it and to all following filenames. Copied files will be read by size (according to the number of bytes indicated in the file`s directory listing). An end-of-file mark is not placed at the end of the copied file.

/V - Checks after the copy to assure that a file was copied correctly. If the copy cannot be verified, the program will display an error message. Using this option will result in a slower copying process.


the command xcopy can do the task like this but it is too old.
Better use robocopy its mus faster and you have lot of swithches as well.

ref.


Popular posts from this blog

เทคนิค ชนะ เกมเศรษฐี 14 ตารวด!!! ( Let's get Rich )

Using Google Chrome Inspect Element to Analyze the website

Easy way to download whole youtube play list and convert them to mp3