It would really help if you posted the .bat code you have working. Without that all I can say, based on the code you linked to, is you probably need to add something like:
First add this near the top:
setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
Then (and I didn't rewrite the old code, but the 2 new lines at the end should be what you need):
FOR %F IN (C:\temp\source\*.*) DO IF !SrcCount! LSS %SrcMax% (
SET /A SrcCount += 1
ECHO !SrcCount! COPY %F C:\temp\output
COPY %F C:\temp\output
rem ** Here are the new lines **
SET FNAME=%%~nF
XCOPY /s "C:\game\store\0.1.2\sky\stuff\!FNAME:~3!" "C:\game\mod\0.1.2\sky\stuff\!FNAME:~3!\"
)
Update 1
rem @ECHO OFF
setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
SET SrcCount=0
SET SrcMax=15
IF NOT EXIST C:\game\mod\0.1.2\map\data md C:\game\mod\0.1.2\map\data
IF NOT EXIST C:\game\mod\0.1.2\sky\stuff md C:\game\mod\0.1.2\sky\stuff
FOR %%F IN (C:\game\mod\store\XMLs\*.*) DO IF !SrcCount! LSS %SrcMax% (
SET /A SrcCount += 1
ECHO !SrcCount! COPY %%F C:\game\mod\0.1.2\map\data\
COPY %%F C:\game\mod\0.1.2\map\data\
SET FNAME=%%~nF
ECHO XCOPY /s "C:\game\mod\store\models\!FNAME:~3!" "C:\game\mod\0.1.2\sky\stuff\!FNAME:~3!\"
XCOPY /s "C:\game\mod\store\models\!FNAME:~3!" "C:\game\mod\0.1.2\sky\stuff\!FNAME:~3!\"
)
Here's my file system before:
C:\game>dir /s /b
C:\game\mod
C:\game\mod\store
C:\game\mod\store\models
C:\game\mod\store\XMLs
C:\game\mod\store\models\01_aaa
C:\game\mod\store\models\01_aaa\test.txt
C:\game\mod\store\XMLs\Map01_aaa.xml
Here it is after:
C:\game>dir /s /b
C:\game\mod
C:\game\mod\0.1.2
C:\game\mod\store
C:\game\mod\0.1.2\map
C:\game\mod\0.1.2\sky
C:\game\mod\0.1.2\map\data
C:\game\mod\0.1.2\map\data\Map01_aaa.xml
C:\game\mod\0.1.2\sky\stuff
C:\game\mod\0.1.2\sky\stuff\01_aaa
C:\game\mod\0.1.2\sky\stuff\01_aaa\test.txt
C:\game\mod\store\models
C:\game\mod\store\XMLs
C:\game\mod\store\models\01_aaa
C:\game\mod\store\models\01_aaa\test.txt
C:\game\mod\store\XMLs\Map01_aaa.xml
And here's the output:
D:\bat>docopy.bat
D:\bat>rem @ECHO OFF
D:\bat>setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
D:\bat>SET SrcCount=0
D:\bat>SET SrcMax=15
D:\bat>IF NOT EXIST C:\game\mod\0.1.2\map\data md C:\game\mod\0.1.2\map\data
D:\bat>IF NOT EXIST C:\game\mod\0.1.2\sky\stuff md C:\game\mod\0.1.2\sky\stuff
D:\bat>FOR %F IN (C:\game\mod\store\XMLs\*.*) DO IF !SrcCount! LSS 15 (
SET /A SrcCount += 1
ECHO !SrcCount! COPY %F C:\game\mod\0.1.2\map\data\
COPY %F C:\game\mod\0.1.2\map\data\
SET FNAME=%~nF
ECHO XCOPY /s "C:\game\mod\store\models\!FNAME:~3!" "C:\game\mod\0.1.2\sky\stuff\!FNAME:~3!\"
XCOPY /s "C:\game\mod\store\models\!FNAME:~3!" "C:\game\mod\0.1.2\sky\stuff\!FNAME:~3!\"
)
D:\bat>IF !SrcCount! LSS 15 (
SET /A SrcCount += 1
ECHO !SrcCount! COPY C:\game\mod\store\XMLs\Map01_aaa.xml C:\game\mod\0.1.2\map\data\
COPY C:\game\mod\store\XMLs\Map01_aaa.xml C:\game\mod\0.1.2\map\data\
SET FNAME=Map01_aaa
ECHO XCOPY /s "C:\game\mod\store\models\!FNAME:~3!" "C:\game\mod\0.1.2\sky\stuff\!FNAME:~3!\"
XCOPY /s "C:\game\mod\store\models\!FNAME:~3!" "C:\game\mod\0.1.2\sky\stuff\!FNAME:~3!\"
)
1 COPY C:\game\mod\store\XMLs\Map01_aaa.xml C:\game\mod\0.1.2\map\data\
1 file(s) copied.
XCOPY /s "C:\game\mod\store\models\01_aaa" "C:\game\mod\0.1.2\sky\stuff\01_aaa\"
C:\game\mod\store\models\01_aaa\test.txt
1 File(s) copied
D:\bat>c:
C:\game>dir /s /b
The code is working on my machine. I don't know how I can be of more help.
Update 2
What does !FNAME:~3! mean, particularly, ~3?
It's a substring operation, it drops the first three characters.
We start out with something like Map01_aaa.xml
in %%F:
SET FNAME=%%~nF
Pulls out just the file name, Map01_aaa
. Then:
!FNAME:~3!
Drops the first 3 characters for 01_aaa
, which you indicated was the needed directory name.
C:\>set test=abcdef
c:\>echo !test:~3!
def
set /?
May also specify substrings for an expansion.
%PATH:~10,5%
would expand the PATH environment variable, and then use only the 5
characters that begin at the 11th (offset 10) character of the expanded
result.
Update 3
And my bad, the folder name is actually 01_aaa_map and so on.
Then change:
XCOPY /s "C:\game\mod\store\models\!FNAME:~3!" "C:\game\mod\0.1.2\sky\stuff\!FNAME:~3!\"
To:
XCOPY /s "C:\game\mod\store\models\!FNAME:~3!_map" "C:\game\mod\0.1.2\sky\stuff\!FNAME:~3!_map\"