Home > Questions

How can I sync local folders to an external hard drive with writing a script file?

Hi, I want to sync my local folders to an external HDD. Is there a way to do so by writing a script file (the local folder should be master)?

Best Answered by

iBoysoft author Ciki Liu

Ciki Liu

Answered on Tuesday, December 3, 2024

 

Since you didn't mention which operating system you are using, there're different script files you can choose from to sync local folders to your external HDD, including cp, copy, xcopy, robocopy, and rsync.

For Linux or Unix users, you can make use of the default cp command. For example, by writing the -r switch, you can copy directories recursively. By writing the -u switch, you can copy only when the source file is newer than the destination file or when the destination file is missing.

If you are using the Windows operating system, unfortunately, the normal commands such as copy and xcopy don't have the same switch as the cp command. Although you can use a FOR loop in a bat file to check the file one by one, the whole copy-paste process can take a very long time

Instead of using copy and xcopy, Windows users have way more options. For example, robocopy has a list of switches to copy file data from one location to another. The basic cmd runs as follows:

robocopy <source> <destination> [<file>[ ...]] [<options>]

One more option is rsync, a fast, versatile, and remote (and local) file-copying tool that can work with macOS. By using switches such as -t and -u, it's particularly convenient to compare files using checksums rather than just dates when copying data. This allows you to transfer only the portions of the files that have changed, which can speed up the copy process. 

People Also Ask

Read More Questions

Read More Advice From iBoysoft's Computer Experts

Disco duro externo que no se monta en Mac

Disco Duro Externo No se Monta en macOS Sonoma/Ventura

8 soluciones efectivas para solucionar el problema de que el disco duro externo no se monta en macOS Sonoma/Ventura/Monterey/Big Sur y recuperar datos perdidos de un disco duro externo no montado en Mac.

recuperacion de datos mac

WD externe Festplatte wird auf dem Mac nicht eingebunden

[Gelöst] WD externe Festplatte wird auf Mac nicht eingehängt

WD externe Festplatte wird auf Mac nicht eingehängt? In diesem Tutorial wird gezeigt, wie Sie das Problem beheben können, dass WD My Passport auf macOS Big Sur 11/Catalina 10.15/Mojave 10.14/High Sierra nicht eingehängt/angezeigt/erkannt wird.

Tipps zur Mac-Datenwiederherstellung

MBR vs GPT

MBR vs GPT: Diferencias entre partición MBR y GPT

MBR vs GPT, ¿cuál es la diferencia y cuál es mejor para tus dispositivos de almacenamiento, especialmente HDD y SSD? Encuentra las respuestas aquí.