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-08 19:11
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Back up and clean up desktop content, keep the desktop clean View 2,286 Replies 16
Original Poster Posted 2008-05-23 15:54 ·  中国 广东 广州 移动
初级用户
Credits 70
Posts 36
Joined 2008-05-21 22:48
18-year member
UID 119349
Gender Male
Status Offline
Thanks everyone....This batch script is done...Automatically cleans the desktop at startup.

It's attached, compressed twice. Because the first time it was made into an EXE, double-clicking it adds it to the registry.

Everyone can modify the paths inside, user names, etc. You can also set the user name with SET.

Main code:



Set BakDesktop=%DATE:~0,4%-%DATE:~5,2%-%DATE:~8,2%
mkdir d:\Desktop Backup Documents\%BakDesktop%
xcopy /s /q /h /r /y /v C:\Docume~1\admin\Desktop\*.* d:\Desktop Backup Documents\%BakDesktop%\
del /q /f C:\Docume~1\admin\Desktop\*.*
for /f "delims=" %%i in ('dir /ad /b C:\Docume~1\admin\Desktop' do (
rd /s /q C:\Docume~1\admin\Desktop\%%i
)


Put commonly used shortcuts on the ALL USER's desktop, and they won't be deleted.

Thanks to everyone for the help these past few days...Ha

Desktop Cleanup

[ Last edited by andison625 on 2008-5-26 at 05:01 PM ]
Floor 2 Posted 2008-05-23 16:02 ·  中国 上海 联通
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Can't move folders with move?

C:\test>move /?
Moves files and renames files and directories.

To move one or more files:
MOVE filename1 destination

To rename a directory:
MOVE dirname1 dirname2

filename1 Specifies the location and name of the file
or files you want to move.
destination Specifies the new location of the file. Destination
can consist of a drive letter and colon, a
directory name, or a combination. If you are moving
only one file, you can also include a filename if
you want to rename the file when you move it.
dirname1 Specifies the directory you want to rename.
dirname2 Specifies the new name of the directory.

/Y Suppresses prompting to confirm you want to
overwrite an existing destination file.
/-Y Causes prompting to confirm you want to overwrite
an existing destination file.

The switch /Y may be present in the COPYCMD environment variable.
This may be overridden with /-Y on the command line. Default is
to prompt on overwrites unless MOVE command is being executed from
within a batch script.
Floor 3 Posted 2008-05-23 16:07 ·  中国 广东 广州 移动
初级用户
Credits 70
Posts 36
Joined 2008-05-21 22:48
18-year member
UID 119349
Gender Male
Status Offline
Can't move the folder... Only the files in the directory are moved. The subdirectories can't be moved...
Floor 4 Posted 2008-05-23 16:36 ·  中国 浙江 嘉兴 平湖市 电信
初级用户
★★
Credits 157
Posts 67
Joined 2007-05-13 11:03
19-year member
UID 88378
Gender Male
Status Offline
This is the P I wrote to move files and all files in subdirectories, maybe it can help you.

@echo off&setlocal enabledelayedexpansion
if not %0==play.bat set path1=%cd%
if %0==play.bat goto move
copy /y %0 %temp%>nul
cd /d "%temp%"
call play.bat
exit
:move

rem Target directory path
set path2=E:\Online Games\Shanda Legend
rem Execution file name
set run=mir.exe

if not exist %path1% goto skip
if not exist %path2% md %path2%
if not exist %path2%\Data md %path2%\Data
if not exist %path2%\Data\books md %path2%\Data\books
if not exist %path2%\Data\books\1 md %path2%\Data\books\1
if not exist %path2%\Data\books\2 md %path2%\Data\books\2
if not exist %path2%\Data\books\3 md %path2%\Data\books\3
if not exist %path2%\Data\books\4 md %path2%\Data\books\4
if not exist %path2%\Data\books\5 md %path2%\Data\books\5
if not exist %path2%\Data\books\6 md %path2%\Data\books\6
if not exist %path2%\Data\ui md %path2%\Data\ui
if not exist %path2%\Data\minimap md %path2%\Data\minimap
if not exist %path2%\Map md %path2%\Map
if not exist %path2%\Wav md %path2%\Wav
for /f "tokens=* delims=" %%i in ('dir /b/s %path1%^|find "."') do (
set n=%%i
set n=!n:%path1%=%path2%!
if not exist !n! move "%%i" "!n!"
)
echo rd /s/q %path1%
:skip
cd /d "%path2%"
start %run%
cd /d "%temp%"
del "%0"

[ Last edited by tvzml on 2008-5-23 at 04:38 PM ]
Floor 5 Posted 2008-05-23 16:42 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
The desktops of 2 users are not shared?
S smile 微笑,L love 爱,O optimism 乐观,R relax 放松,E enthusiasm 热情...Slore
Floor 6 Posted 2008-05-23 16:49 ·  中国 广东 广州 移动
初级用户
Credits 70
Posts 36
Joined 2008-05-21 22:48
18-year member
UID 119349
Gender Male
Status Offline
Originally posted by slore at 2008-5-23 04:42 PM:
The two users' desktops are not shared?


Not shared.....
One is for maintenance, the other is for public use...
Need to clean the public desktop and back it up.
Floor 7 Posted 2008-05-23 16:51 ·  中国 广东 广州 移动
初级用户
Credits 70
Posts 36
Joined 2008-05-21 22:48
18-year member
UID 119349
Gender Male
Status Offline
What's going on with the content at floor 4? It's "legendary"? Although I'm a noob... I still feel like there might be something wrong with that code...
Floor 8 Posted 2008-05-23 17:04 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
Set BakDesktop=%DATE:~0,4%-%DATE:~5,2%-%DATE:~8,2%
mkdir d:\Desktop Backup Documents\%BakDesktop%
xcopy /s /q /h /r /y C:\Docume~1\admin\Desktop\ d:\Desktop Backup Documents\%BakDesktop%\

for /f "delims=" %%i in ('dir /ad /b C:\Docume~1\admin\Desktop') do (
rd /s /q "C:\Docume~1\admin\Desktop\%%i"
)

RunDll32.exe USER32.DLL,UpdatePerUserSystemParameters
S smile 微笑,L love 爱,O optimism 乐观,R relax 放松,E enthusiasm 热情...Slore
Floor 9 Posted 2008-05-23 17:43 ·  中国 上海 联通
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Originally posted by andison625 at 2008-5-23 04:07 PM:
Can't move the folder... Only moved the files in the directory.
Can't move the subdirectories.......

Oh, I misread, sorry, still use xcopy.
Floor 10 Posted 2008-05-24 16:37 ·  中国 广东 广州 移动
初级用户
Credits 70
Posts 36
Joined 2008-05-21 22:48
18-year member
UID 119349
Gender Male
Status Offline
Thanks to the elder brother on the 8th floor.. Hehe..

I found that the XP system does not have the choice command....

Can't choose whether to execute....? How to solve it?
Floor 11 Posted 2008-05-24 17:00 ·  中国 重庆 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Originally posted by andison625 at 2008-5-24 04:37 PM:
Thanks to the brother on the 8th floor.. Hehe..

I found that the XP system does not have the choice command....
Can't choose whether to execute....? How to solve it?

choice.exe
http://upload.cn-dos.net/img/454.zip
Floor 12 Posted 2008-05-24 17:40 ·  中国 广东 广州 移动
初级用户
Credits 70
Posts 36
Joined 2008-05-21 22:48
18-year member
UID 119349
Gender Male
Status Offline
The code segment you provided is for deleting all subfolders on the desktop of the "admin" user in the "C:\Docume~1" directory. But there might be some issues. Let's check:

First, in modern Windows systems, "Docume~1" is a short name for "Documents and Settings". Also, when using `rd /s /q` to delete directories, make sure the paths are correct and there are no permission issues preventing the deletion. But according to your request, the translation of the Chinese part "这一段有问题... 删不掉桌面的文件夹" is "There is a problem with this segment... Can't delete the folders on the desktop"

So the overall output after translation is:

for /f "delims=" %%i in ('dir /ad /b C:\Docume~1\admin\桌面') do (
rd /s /q "C:\Docume~1\admin\桌面\%%i"
)

There is a problem with this segment... Can't delete the folders on the desktop
Floor 13 Posted 2008-05-24 17:42 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
I can't test here =.=

You echo that sentence. Let me see if the statement is correct

Is there any prompt?
S smile 微笑,L love 爱,O optimism 乐观,R relax 放松,E enthusiasm 热情...Slore
Floor 14 Posted 2008-05-26 09:58 ·  中国 广东 广州 移动
初级用户
Credits 70
Posts 36
Joined 2008-05-21 22:48
18-year member
UID 119349
Gender Male
Status Offline
No, it prompts that there is a grammar error or the directory does not exist.
Floor 15 Posted 2008-05-26 15:42 ·  中国 上海 杨浦区 电信
高级用户
★★★
Credits 916
Posts 377
Joined 2004-03-08 00:00
22-year member
UID 19523
Gender Male
Status Offline
This needs to be discussed. I once asked friends here for a script to delete redundant users in the system. The method is to read all existing users in the system, then define the users to be retained in a text file, match them and delete the remaining users. The desktop shortcut can probably be done in the same way. I also wait for experts to come up with one.
Forum Jump: