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 07:01
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Question about what's wrong with my batch file View 803 Replies 12
Original Poster Posted 2008-07-23 11:03 ·  中国 河南 郑州 电信
初级用户
★★
Credits 123
Posts 62
Joined 2008-04-09 16:11
18-year member
UID 115362
Gender Male
Status Offline
set /p filename=Customer Data
set alldrive=f
for %%i in (%alldrive%) do if exist %%i:\ dir /b %%i:| find "%filename%"
move %filename% e:\win
pause


The original idea was to search for Customer Data under all drive letters and then MOVE it to the e:\win folder, but I found there was a problem so I changed it to search only f:
But after changing it to f:, it still doesn't work
Floor 2 Posted 2008-07-23 11:15 ·  中国 广东 广州 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline
I'm puzzled too. Sometimes with find "string", the string is clearly there, but it just won't show up.
I just tested it, and with find "string", the string is case-sensitive.
I searched for the If_Exist folder, success
if_exist did not work
Floor 3 Posted 2008-07-23 11:26 ·  中国 河南 郑州 电信
初级用户
★★
Credits 123
Posts 62
Joined 2008-04-09 16:11
18-year member
UID 115362
Gender Male
Status Offline
I'm really puzzled... I've already tested the letter case and it still doesn't work..
For example, if what I'm searching for is "Customer Data", do Chinese characters have upper/lower case too??
Floor 4 Posted 2008-07-23 11:32 ·  中国 广东 韶关 电信
高级用户
★★★
CMD感染者
Credits 691
Posts 383
Joined 2008-05-23 00:38
18-year member
UID 119451
Gender Male
Status Offline
set /p filename=Customer Data
In this, "Customer Data" is the displayed prompt text, not the value of filename
Floor 5 Posted 2008-07-23 11:37 ·  美国 惠普HP
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Remove the /p switch from the set command
Floor 6 Posted 2008-07-23 11:41 ·  中国 广东 广州 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline
I feel this batch file has a big problem... it seems...
I was almost driven crazy... this is the code I tested successfully myself

@echo off
set /p filename=":"
if exist f:\%filename% move f:\%filename% e:\

(The check in if exist f:\%filename% already includes checking whether drive f exists, so it's direct and simple)
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
wang6542975 +2 2008-07-23 17:23
Floor 7 Posted 2008-07-23 11:46 ·  中国 河南 郑州 电信
初级用户
★★
Credits 123
Posts 62
Joined 2008-04-09 16:11
18-year member
UID 115362
Gender Male
Status Offline
After removing the /p switch, it can find the Customer Data folder, but it still can't move it, saying access denied. The folder location and file are not the problem..
Still hoping for advice
Floor 8 Posted 2008-07-23 11:51 ·  中国 河南 郑州 电信
初级用户
★★
Credits 123
Posts 62
Joined 2008-04-09 16:11
18-year member
UID 115362
Gender Male
Status Offline
.. It says the system cannot find the specified file, sorry, I misread it.
I thought it was a directory problem, then I put the batch file under the Customer Data folder and ran it, but that still didn't work..
Floor 9 Posted 2008-07-23 12:02 ·  中国 河南 郑州 电信
初级用户
★★
Credits 123
Posts 62
Joined 2008-04-09 16:11
18-year member
UID 115362
Gender Male
Status Offline
It seems to be a problem with the MOVE command.
Floor 10 Posted 2008-07-23 14:27 ·  中国 广东 广州 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline
Depressing, extremely depressing!!!
(Hope you can take screenshots of the relevant images and post them in the thread so everyone can have a look)
Floor 11 Posted 2008-07-23 17:11 ·  中国 广东 广州 电信
银牌会员
★★★
永远的菜鸟
Credits 1,335
Posts 574
Joined 2007-11-27 12:50
18-year member
UID 103929
Gender Male
From 广西
Status Offline
@echo off
for %%a in (c d e f g h i j k l m n) do (
if exist %%a: (
for /f "delims=" %%b in ('dir /s/b %%a:^|find /i "Customer Data"') do (
echo move /y "%%b" e:\win\
)
)
)
Pause
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
wang6542975 +2 2008-07-23 17:22
Floor 12 Posted 2008-07-23 17:25 ·  中国 河南 郑州 电信
初级用户
★★
Credits 123
Posts 62
Joined 2008-04-09 16:11
18-year member
UID 115362
Gender Male
Status Offline
Such a clear line of thinking is really worth studying carefully!!
By the way, what if it's a folder named "Customer Data"?
MOVE the "Customer Data" folder to E:\WIN
I tried it, and it seems rather difficult..
Floor 13 Posted 2008-07-23 17:55 ·  中国 广东 广州 电信
银牌会员
★★★
永远的菜鸟
Credits 1,335
Posts 574
Joined 2007-11-27 12:50
18-year member
UID 103929
Gender Male
From 广西
Status Offline
Try this?
@echo off
for %%a in (c d e f g h i j k l m n) do (
if exist %%a: (
for /f "delims=" %%b in ('dir /s/b/ad "%%a:\*"^|findstr /i /e "\\客户资料"') do (
echo move /y "%%b" e:\win\
)
)
)
Pause
Forum Jump: