China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-09 16:59
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Question about excluding special directories and files when copying files View 922 Replies 13
Original Poster Posted 2008-09-04 16:12 ·  中国 广东 广州 荔湾区 电信
新手上路
Credits 16
Posts 7
Joined 2008-09-04 15:42
17-year member
UID 124781
Gender Male
Status Offline
--output
--projects
--project1
--bin
--debug
project1.dll
project1.xml
--release
project1.dll
project1.xml
--obj
--debug
project1.dll
project1.xml
project1.pda
--release
project1.dll
project1.xml
--project2
--bin
--debug
project1.dll
project2.dll
project2.xml
--obj
--debug
project1.dll
project1.xml
project1.pda
..............
The output folder and the projects folder are at the same level. Inside the projects folder there are multiple project folders . Each project folder has a bin folder and an obj folder, and inside the bin folder and obj folder there are debug and release folders. Now I want to copy the contents of the debug folder inside the bin folder into output, but not the ones in obj. Also, because project2 also has a file called project1.dll, I need to skip that file. This batch file is too hard for me. Please give me a hand.

[ Last edited by iipiip on 2008-9-4 at 04:14 PM ]
Floor 2 Posted 2008-09-04 16:17 ·  中国 广东 广州 越秀区 电信
新手上路
Credits 16
Posts 7
Joined 2008-09-04 15:42
17-year member
UID 124781
Gender Male
Status Offline
It should be copying the *.dll and *.xml files from the debug folder inside the bin folder into the output folder
Floor 3 Posted 2008-09-04 16:32 ·  美国 惠普HP
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Do you mean this?
@echo off
set SrcDir=C:\test\projects
set DstDir=C:\test\output
for /f "tokens=*" %%a in ('dir /s /b /a-d "%SrcDir%"^|findstr /i "\\bin\\"') do (
echo n|copy /-y "%%a" "%DstDir%"
)
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
iipiip +1 2008-09-04 16:55
Floor 4 Posted 2008-09-04 16:33 ·  美国 惠普HP
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Uh, the requirements changed.
@echo off
set SrcDir=C:\test\projects
set DstDir=C:\test\output
for /f "tokens=*" %%a in ('dir /s /b /a-d "%SrcDir%"^|findstr /i "\\bin\\debug\\"') do (
echo n|copy /-y "%%a" "%DstDir%"
)
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
iipiip +1 2008-09-04 16:55
Floor 5 Posted 2008-09-04 16:40 ·  中国 广东 广州 越秀区 电信
新手上路
Credits 16
Posts 7
Joined 2008-09-04 15:42
17-year member
UID 124781
Gender Male
Status Offline
Thank you so much................................
Floor 6 Posted 2008-09-04 16:44 ·  中国 广东 广州 越秀区 电信
新手上路
Credits 16
Posts 7
Joined 2008-09-04 15:42
17-year member
UID 124781
Gender Male
Status Offline
But I still have one more question. Right now project2 comes after project1. If project2 comes before project1, then the dll inside project1 won't overwrite project2's, right? What I mean is, the one coming out of the project1 folder, and then the ones from other folders, should not overwrite it. Can this be done? Sorry to trouble HATle again

These dll names are definitely the project names,
Floor 7 Posted 2008-09-04 16:49 ·  美国 惠普HP
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
The results of dir should be sorted in ascending order by default, so project1 is automatically placed before project2.
echo n is exactly so the later ones won't overwrite the earlier ones.
Floor 8 Posted 2008-09-04 16:52 ·  中国 广东 广州 越秀区 电信
新手上路
Credits 16
Posts 7
Joined 2008-09-04 15:42
17-year member
UID 124781
Gender Male
Status Offline
Uh... the problem is, project1 may not be called project1... I'm just writing it like this for convenience. It could be wpfproject, and project2 could be sileverlightproejct....
Floor 9 Posted 2008-09-04 16:55 ·  美国 惠普HP
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Strings are sorted according to ASCII codes
wpfproject will come after sileverlightproejct
Do you mean you want wpfproject to come before sileverlightproejct?
Floor 10 Posted 2008-09-04 17:03 ·  中国 广东 广州 荔湾区 电信
新手上路
Credits 16
Posts 7
Joined 2008-09-04 15:42
17-year member
UID 124781
Gender Male
Status Offline
Uh... let me put it this way. It's still the same file structure as above, except that the debug folder under project1 has project2.dll
project1
--bin
--debug
project1.dll
project1.xml
project2.dll
--project2
--bin
--debug
project2.dll
project2.xml
What I mean is, when copying, the contents of the debug folder under project1 will definitely be copied first, so then output will have project2.dll, and when project2 gets copied later, it won't overwrite project2.dll. But what I need is for project2.dll inside project2 to overwrite the project2.dll in output. Because project2.dll is produced by the project2 folder. I don't know if you understand what I mean~。~ Thanks again for your help. Thank you
Floor 11 Posted 2008-09-04 17:27 ·  美国 惠普HP
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Floor 12 Posted 2008-09-04 17:28 ·  中国 广东 广州 荔湾区 电信
新手上路
Credits 16
Posts 7
Joined 2008-09-04 15:42
17-year member
UID 124781
Gender Male
Status Offline
Still thanking you................
HAT is a super nice person
Floor 13 Posted 2008-09-05 22:13 ·  中国 北京 海淀区 联通
初级用户
Credits 22
Posts 15
Joined 2008-06-23 05:01
18-year member
UID 120728
Gender Male
Status Offline
Same here, a modern-day Lei Feng
一起蹲坑
Floor 14 Posted 2008-09-06 01:59 ·  中国 广东 东莞 电信
初级用户
Credits 98
Posts 45
Joined 2008-08-30 01:29
17-year member
UID 124535
Gender Male
Status Offline
A bit complicated
Forum Jump: