The standard Windows command line tools like xcopy, rmdir cannot operate with paths longer than MAX_PATH(260 chars). If you want to remove the directory which contains such file which full path is longer than MAX_PATH, or if you want to copy recursively a directory to such a place where the full path to at least one of its files would be longer than MAX_PATH then these command line tools fail.
However you can bypass it with "move" command line tool, because in distinct to xcopy and rmdir(rd) it seems to not iterating the files in the directory one-by-one.
This workaround may be not always convenient and requires additional actions, but for the automation/scripting purpose I don't see any other way if you cannot or don't want using special tools a.k.a robocopy. This way works with a directory, but not with a single file. Let me show an example.
Create a directory. Path length: 245 chars
E:\>mkdir E:\veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryloooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongdirectory
Thy to create a file inside it so that the file path length is bigger than MAX_PATH. Usual way it won't work.
E:\>echo "content" > E:\veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryloooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongdirectory\longlonglonglonglongfilename.txt
The system cannot find the path specified.
Workaround: Create a file(s) with a short path and move the directory containing the file(s) into the long path.
E:\>echo "content" > somedir\longlonglonglonglongfilename.txt
E:\>move somedir E:\veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryloooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongdirectory\
1 dir(s) moved.
Check 1: Was the directory completely moved (with all files)? - Yes.
E:\>dir E:\veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryloooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongdirectory\somedir
Volume in drive E is Workspace
Volume Serial Number is C864-7C96
Directory of E:\veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryloooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongdirectory\somedir
08/09/2019 11:52 AM <DIR> .
08/09/2019 11:52 AM <DIR> ..
08/09/2019 11:52 AM 12 longlonglonglonglongfilename.txt
1 File(s) 12 bytes
2 Dir(s) 130,574,221,312 bytes free
Check 2. The path is really longer than MAX_PATH, that's why it won't be accessible by the full path for the usual command line tools, so we did everything correct:
E:\>dir E:\veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryloooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongdirectory\somedir\longlonglonglonglongfilename.txt
Volume in drive E is Workspace
Volume Serial Number is C864-7C96
Directory of E:\veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryloooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongdirectory\somedir
File Not Found
The same workaround is valid if you want to remove (with rmdir) the directory containing subfolders/files whose path is longer than MAX_PATH. Just move the upper directory to some short temporary location and there you can rmdir it.
NOTE: Windows command line tool "move" can move directories only within the same disk letter.