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-12 18:24
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Experts, please help look at this batch file for an undeletable folder View 4,970 Replies 46
Floor 31 Posted 2008-06-28 19:15 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
Supplement
Replace start "" D:\TMP\sm..\ in the code with start "" "%CurDir%sm..\"
第一高手 第二高手

Floor 32 Posted 2008-06-28 20:04 ·  中国 山西 太原 联通
初级用户
Credits 42
Posts 19
Joined 2005-12-23 21:16
20-year member
UID 47750
Status Offline
The previous poster, I tested 复制.cmd, and it still didn't copy the empty folder into sm..\

[ Last edited by philon on 2008-6-28 at 08:24 PM ]
Floor 33 Posted 2008-06-28 20:46 ·  中国 重庆 九龙坡区 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Even /e doesn't work?

/E Copies directories and subdirectories, including empty ones.
Same as /S /E. May be used to modify /T.
Floor 34 Posted 2008-06-28 20:49 ·  中国 山西 太原 联通
初级用户
Credits 42
Posts 19
Joined 2005-12-23 21:16
20-year member
UID 47750
Status Offline
That's right. After adding /e, it still didn't copy over, and it also gave a cannot perform cyclic copy prompt. Only non-empty directories and the files inside them were copied over; the files in the current directory weren't copied over at all
Floor 35 Posted 2008-06-28 21:00 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
philon +2 2008-06-28 23:32
第一高手 第二高手

Floor 36 Posted 2008-06-28 21:22 ·  中国 山西 太原 联通
初级用户
Credits 42
Posts 19
Joined 2005-12-23 21:16
20-year member
UID 47750
Status Offline
fastslz
You really are an expert, thank you very much! This time it worked. It achieved what I had in mind! Thanks again~
I changed cls&echo Copying file "%~1" ...... to cls&echo Copying file ......
Haha
Floor 37 Posted 2008-06-28 21:31 ·  中国 广东 广州 联通
初级用户
★★
Credits 167
Posts 80
Joined 2005-11-07 05:08
20-year member
UID 44725
Gender Male
Status Offline
Originally posted by HAT at 2008-6-28 17:34:
Add a fox loop to exclude sm..\, then use xcopy /i, maybe it can be done. Going to eat first, we'll discuss it again when I get back.


You could also first copy the files and folders that need to go into the “sm.” folder to somewhere else, and then copy them back.
Floor 38 Posted 2008-06-28 22:08 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
Originally posted by philon at 2008-6-28 21:22:

I changed cls&echo Copying file "%~1" ...... to cls&echo Copying file ......
Haha

:xxxx
cls&echo Copying file%status%
xcopy /y/h/r "%~1" "%~dp2" >nul
set status=%status%.
goto:eof
第一高手 第二高手

Floor 39 Posted 2008-06-28 22:49 ·  中国 山西 移动
初级用户
Credits 42
Posts 19
Joined 2005-12-23 21:16
20-year member
UID 47750
Status Offline
One more question: after using your code, I can't change the name of the folder to be created? Can't sm be changed to another name? For example wd, or simply private folder? Is it related to that 6b7e~1 thing? What is it used for? Waiting for your reply.
Floor 40 Posted 2008-06-28 23:40 ·  中国 重庆 九龙坡区 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Come on, you still haven't figured out where sm6b7e~1 comes from?
Post #12 explained it very clearly, dir /x
Floor 41 Posted 2008-06-28 23:44 ·  中国 广东 广州 联通
初级用户
★★
Credits 167
Posts 80
Joined 2005-11-07 05:08
20-year member
UID 44725
Gender Male
Status Offline
Look at the picture:


Floor 42 Posted 2008-06-28 23:48 ·  中国 山西 移动
初级用户
Credits 42
Posts 19
Joined 2005-12-23 21:16
20-year member
UID 47750
Status Offline
Yeah, it's just that there's no way to change sm to another name.
Floor 43 Posted 2008-06-28 23:52 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
@echo off&mode con cols=70 lines=12
setlocal enabledelayedexpansion
set CurDir=%~dp0
color 5b&cls&echo.
set /p Name=Enter a folder name! Folder names with spaces are not supported
if not defined Name color 0c&cls&echo.&echo You didn't enter any characters!&&ping/n 3 127.1>nul&exit
title Create or delete a private folder
if not exist %Name%..\nul (
md "%Name%..\"
for /f "skip=1 tokens=4*" %%a in ('dir/ad/x "%CurDir%%Name%.*"') do if not defined ShortName set "ShortName=%%a"
color 5a&cls&echo.&echo The private folder has been created! Files will be put into the private folder...&ping/n 2 127.1>nul
for /f "delims=*" %%a in ('dir/ad/s/b "%CurDir%"^|findstr /i /v "\%Name%."') do md "%CurDir%!ShortName!\%%~nxa"
for /f "delims=*" %%i in ('dir/a-d/s/b "%CurDir%"^|findstr /i /v "\%Name%. .bat .cmd"') do (
set "SourceFile=%%i"
set "DestinationFile=!SourceFile:%CurDir%=!"
call :xxxx "!SourceFile!" "%CurDir%!ShortName!\!DestinationFile!"
)
ping/n 2 127.1>nul
start "" "%CurDir%%Name%..\"
) else (
rd /s/q "%Name%..\"
color 5e&cls&echo.&echo The private folder has been deleted!&ping/n 2 127.1>nul
)
color 5b&cls&echo.&echo Run it again to recreate or delete!&ping/n 2 127.1>nul
exit

:xxxx
if not defined count set count=0
if %count% gtr 50 set status=.&set count=1
cls&echo Copying file%status%..
xcopy /y/h/r "%~1" "%~dp2" >nul
set status=%status%.&set /a count+=1
goto:eof


When the Name variable is undefined or defined as space characters, rd /s/q %Name%..\ will delete all folders in the parent directory. Any loss has nothing to do with me, so please do not casually modify the code
第一高手 第二高手

Floor 44 Posted 2008-06-28 23:53 ·  中国 江苏 苏州 昆山市 电信
高级用户
★★
五星老土
Credits 558
Posts 172
Joined 2003-02-09 00:00
23-year member
UID 881
Gender Male
From 江苏
Status Offline
Actually, this kind of folder is also easy to delete, so it can't really be called a private folder.

Because just like post #12 said, dir/x shows everything.

For example, with md g..\ you can actually cd ge276~1, and then do whatever you want. Same principle as sm6b7e~1
我怎么找不到一个比我注册日期早的人? 难道我是传说中的超级管理员? 其实我只是个潜水冠军而已.
Floor 45 Posted 2008-06-29 01:15 ·  中国 山西 太原 联通
初级用户
Credits 42
Posts 19
Joined 2005-12-23 21:16
20-year member
UID 47750
Status Offline
Forum Jump: