Given that you are using robocopy, a Windows-only utility, I'm assuming you can run a batch script.
The following script will do what you are looking for, and it does not need to be run from any of the folders in question, in case you cannot write to them.
@echo off
setlocal enableextensions enabledelayedexpansion
for /f "delims=" %%A in ('dir /a:d /b "C:/MyFolder"') do (
set folder=%%A
set firstFourChars=!folder:~0,4!
if NOT "!firstFourChars!" == "http" (robocopy "C:/MyFolder/%%A" "D:/MyFolder/%%A" /MIR /XJ /NDL /NP /TEE /S)
)
Explanation:
@echo off
declutters the output, stopping the interpreter from saying every command it runs.
setlocal enableextensions enabledelayedexpansion
makes the for loop work, by making the instructions contained within (...)
to be executed one by one, and allowing access to current state of variables with !var!
syntax.
for /f "delims=" %%A in ('dir /a:d /b "C:/MyFolder"') do (...)
loops over all folders in C:/MyFolder
. "delims="
is necessary to support folder name with spaces.
set folder=%%A
sets the name of each folder to the variable called folder
.
set firstFourChars=!folder:~0,4!
sets the first four characters of every folder's name to the variable named firstFourChars
.
if NOT "!firstFourChars!" == "http" (robocopy "C:/MyFolder/%%A" "D:/MyFolder/%%A" /MIR /XJ /NDL /NP /TEE /S)
runs your robocopy
command only if said first four characters do not match the literal http
.
/XD http*
.