Perbedaan Copy dengan Xcopy pada Cmd Batch



YUANPAPER Logo
>
Bagaimana jika kita ingin meng-copy satu folder sekaligus?
Kita juga bisa menggunakan perintah copy biasa, akan tetapi nama folder tersebut tidak ikut tercopy, yang tercopy hanya isinya doang. Disinilah kita bisa menggunakan perintah " xcopy ". Misalkan kita ingin mengcopy folder di Drive D: yang terdiri dari banyak sub folder maka kita bisa ketikkan perintah " xcopy /e [namafolder] [drive tutujuan ]. " /e " merupakan perintah untuk melakukan copy terhadap subdirectory.

xcopy copy does not know how you want to handle the destination. I would recommend you xcopy /? to display a list of switches. In your case your have two choices. If i remember correctly copy command use to copy 1file a time, xcopy however, can copy a whole folder plust subdir if correct switch is used 
1. use copy command instead of xcopy 
2. add /I switch right behind the /Y switch, this usually does the trick in copying the whole folder. I'm not specifically sure for file, but i bet it should silently/automatically copy it for you.

echo f | xcopy source_folder\file.txt destination_folder\file.txt 
or 
echo d | xcopy source_folder\file.txt destination_folder\file.txt 

Ada juga cara lain jika kita ingin mencopy dengan praktis dan cepat yakni dengan menggunakan extensi file tertentu. Contohnya jika saya ingin mengcopy semua file yang berekstensi *.txt yang ada di drive D: maka saya bisa ketikkan perintah " xcopy /s *.txt C:\newFolder ", maka setiap file dengan extensi *.txt akan tercopy ke folder newFolder di drive C.

The @ symbol before the ECHO command means that the ECHO command will stay throughout the whole batch file unless turned on again. Without the @, it will only apply to the command directly after it.

ECHO can also be used to relay a message aswell
Example :
ECHO Your computer is working fine.
Will have the Command window say : "Your computer is working fine."

rmdir /s /q "C:\dummy"


LOAD DISCUSSION