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-06-24 16:31
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Original] [XP] File Backup Utility V2.4 (Final) [Updated on 07-4-8] DigestI View 34,135 Replies 112
Floor 91 Posted 2006-10-19 22:09 ·  中国 广东 电信
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
Originally posted by uemuem at 2006-10-14 01:57:
When the source file does not exist but the backup file exists, the backup file cannot be restored to the source file location, and there is no error prompt...

  I have never been able to reproduce this problem on my machine, and I can't figure out where the problem is for the time being. You'd better test several times. If it still can't be restored, please tell me every step you take.
  However, I did find during the test that when copying a certain sub - file fails, this program cannot fully back up the file. As for under what circumstances the copy will fail, it is still unknown for the time being; however, the probability of copy failure is very low, so you can use it with confidence.
Originally posted by TQang at 2006-9-20 23:14:
The xcopy_parameter parameter is not used, is there a bit of a BUG

  It does belong to the behavior of wasting variables. It has been corrected. Please download and test on the top floor.
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 92 Posted 2006-10-21 07:32 ·  中国 西藏 拉萨 联通
中级用户
★★
Credits 254
Posts 63
Joined 2003-04-08 00:00
23-year member
UID 1430
Gender Male
Status Offline
Unable to download the attachment
Floor 93 Posted 2006-10-21 08:50 ·  中国 广东 佛山 广东睿江科技有限公司
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
Originally posted by wangjf at 2006-10-21 07:32:
Unable to download attachments

  The compressed package contains both bat and exe formats, and there is also an instruction file. I tested it and found that it can be downloaded, but the downloaded file cannot be opened normally and cannot be deleted normally. I also found similar problems when downloading other files before. It should be a problem with the forum's download system. Please download at another time or directly copy the code in the top post.
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 94 Posted 2006-10-21 21:52 ·  中国 西藏 拉萨 联通
中级用户
★★
Credits 254
Posts 63
Joined 2003-04-08 00:00
23-year member
UID 1430
Gender Male
Status Offline
It has been downloadable and can be opened normally. Thanks to the LZ for the timely update.
Floor 95 Posted 2006-11-24 15:28 ·  中国 北京 鹏博士BGP
初级用户
Credits 114
Posts 47
Joined 2006-11-20 04:17
19-year member
UID 71105
Gender Male
Status Offline
Learning
Floor 96 Posted 2007-04-06 13:42 ·  中国 广东 深圳 宝安区 电信
初级用户
Credits 20
Posts 10
Joined 2007-04-06 06:20
19-year member
UID 84144
Gender Male
Status Offline
Thanks to the LZ for sharing! It will definitely come in handy in the future
Floor 97 Posted 2007-04-09 00:23 ·  中国 广东 电信
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
After being suspended for nearly half a year, the code is updated again. If there are no major bugs, it will be released as the final version. Please test it if you are interested.
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 98 Posted 2007-04-09 04:38 ·  中国 江西 吉安 电信
初级用户
Credits 21
Posts 10
Joined 2007-04-02 04:04
19-year member
UID 83677
Gender Male
Status Offline
Not bad
Keep up the good work!
Floor 99 Posted 2007-04-09 05:26 ·  中国 广东 肇庆 电信
初级用户
★★
Credits 152
Posts 74
Joined 2005-12-01 23:06
20-year member
UID 46314
Status Offline
Good stuff, top it up
Floor 100 Posted 2007-04-09 07:53 ·  中国 广东 广州 天河区 电信
银牌会员
★★★
Credits 1,206
Posts 517
Joined 2007-03-25 01:18
19-year member
UID 82819
Gender Male
Status Offline
To be honest, if there are no command-line arguments added, this script is basically useless.
知,不觉多。不知,乃求知
Floor 101 Posted 2007-04-09 08:05 ·  中国 甘肃 平凉 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
Originally posted by flyinspace at 2007-4-9 07:53:
To be honest, this script is basically useless without command-line arguments.

That's completely wrong~At least it can be learned.
Floor 102 Posted 2007-04-09 08:37 ·  中国 广东 广州 天河区 电信
银牌会员
★★★
Credits 1,206
Posts 517
Joined 2007-03-25 01:18
19-year member
UID 82819
Gender Male
Status Offline
set /p source= Please enter the path of the file to be backed up:
set "source=%source:"=%"
:: The above sentence is to judge whether there are quotes in %source%, and if so, remove them.
if "%source%"==":" goto input_source
if "%source%"=="0" exit
if "%source%"=="1" goto notice
if "%source%"=="2" goto backup_tasks
if /i "%source%"=="v" goto view_batch
if not exist "%source%" goto source_noexist
for %%i in ("%source%") do if "%%~fi"=="%%~di\" goto forbid_to_backup
:: Judge whether the file to be backed up is a file or a folder, and set a flag for the subsequent xcopy operation
pushd "%source%" 2>nul && (popd & set folder=yes) || (set folder=)

When the input is empty, we use
if /i "%source%"=="" goto ***

if /i "%source%"=="%*" goto ***
This is to solve.
In this way, when the target does not exist.
You can get error messages in time for correction.
In addition, when the copied file is running or occupied.

Has the building owner considered writing a log (giving a prompt) and then continuing or stopping the copy?

As for illegal characters, it is also very easy to defend, write a subroutine.
Using code like %data:~0,1% can be done.
Building owner, please don't take this as the final code:)

There is still a lot to update:)

Hehe, analyze your code after eating.
知,不觉多。不知,乃求知
Floor 103 Posted 2007-04-09 08:52 ·  中国 甘肃 平凉 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
Originally posted by flyinspace at 2007-4-9 08:37:
set /p source= Please enter the path of the file to be backed up:
set "source=%source:"=%"
:: The above line is to judge whether there are quotes in %source%, and if so, remove them.
if "%source%&qu ...


What you said is not completely correct. I think this is the perfect solution

http://www.cn-dos.net/forum/viewthread.php?tid=29367&fpage=1&highlight=

[ Last edited by vkill on 2007-4-9 at 09:36 AM ]
Floor 104 Posted 2007-04-09 10:19 ·  中国 辽宁 丹东 联通
初级用户
★★
Credits 116
Posts 56
Joined 2007-03-07 04:53
19-year member
UID 80966
Gender Male
Status Offline
VKILL is strong
QQ=3391617
Floor 105 Posted 2007-04-09 21:57 ·  中国 广东 电信
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
1、
Originally posted by flyinspace at 2007-4-8 18:53:
To be honest, if no command-line parameters are added, this script is basically useless.

  From your other replies, it can be seen that you are a person in programming, but saying such a thing is somewhat unexpected. Let's ask: In an object-oriented high-level language, if the properties of the object are not provided for you to select/modify, is the program compiled a crippled thing? Does such a language resemble a castrated eunuch?

  2、

When the input is empty, we use
if /i "%source%"=="" goto ***
if /i "%source%"=="%*" goto ***
This is used to solve. .
In this way, when the target does not exist. .
Error information can be obtained in time for correction. .

  It can be said that there are several methods to judge whether the input is empty, and error information can be obtained in time. For example, there is also the if not defined statement. The method you provided is indeed feasible in other cases, but you may not have noticed this description in the previous tag segment:
set source=:
:: The above sentence is to lay the groundwork for removing quotes later, the colon must not be omitted; otherwise, an error will occur when pressing Enter when the input is empty.

Specific problems should be analyzed specifically, and should not be confined to a fixed way of thinking.

  3、
In addition, when the copied file is running or occupied.
Did the landlord consider writing to the log (giving a prompt) and then continuing or stopping the copy?

  The method of renaming seems to simply judge whether the file is running or occupied, but this method has great drawbacks: when there are many files to be copied, because the file name needs to be restored, the execution efficiency of the code will be relatively low. In the first few versions, I would add "system + read-only" attributes to the backed-up files. In this version, I have canceled this operation. The problem of execution efficiency is also one of the reasons, so for the same reason, I don't plan to add this function. If everyone thinks it is necessary, this function will be added in subsequent versions.

  4、
As for illegal characters, it is also very easy to prevent, write a subroutine.
Using code like %data:~0,1% can be done. .

  Regarding the prevention of illegal characters, it doesn't seem as simple as you said. For specific reasons, please refer to the analysis of willsort on floor 13 of this post.

  5、
楼主, please don't take this as the final code :)
There are still a lot of updates needed :)
Hehe, I'll analyze your code after eating.

  Thank you for your patient analysis. More deficiencies need to be discovered by people like you who are patient to test (such as point 3). However, as I said in the update history, if there are no major bugs in this version, I will no longer update the code, because my current energy is somewhat limited, and I can't make more in-depth considerations for irrelevant details.
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Forum Jump: