|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 61 楼』:
使用 LLM 解释/回答一下
因为在备份的时候,为了防止对备份后文件进行改动,备份后的所有文件都已经设置成"系统+只读"属性,如果在恢复文件的时候,不恢复这些文件的原始属性,会导致一些意想不到的问题:比如说不能再对恢复后的文件进行诸如改名、更新内容等操作。这也是我在恢复文件的时候才发现的问题,所以增加了对属性的操作。
当然,在备份的时候,是可以用参数/k来保持原始的属性,但是这样做了之后,就不能防止对备份后的文件进行改动。为了备份文件的保险起见,还是弄复杂点的好:)
Because when backing up, in order to prevent changes to the files after backup, all files after backup have been set to "system + read-only" attributes. If the original attributes of these files are not restored when restoring the files, some unexpected problems will occur: for example, operations such as renaming and updating the content of the restored files can no longer be performed. This is also a problem I discovered when restoring the files, so the operation of attributes is added.
Of course, when backing up, the /k parameter can be used to maintain the original attributes, but after doing this, changes to the files after backup cannot be prevented. For the safety of backing up files, it is better to make it more complicated :)
|
|
2006-6-29 22:59 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 62 楼』:
使用 LLM 解释/回答一下
在回其他帖子的时候,再次查看了这个脚本中对日期的检测这段代码,发现如果要对星期式日期的输入作检测,其原理和对数字式日期的检测其实是一样的,只不过要用到findstr命令中的某个技巧而已,于是马上挑灯夜战,完善了对日期的检测。
When replying to other posts, I checked the code for date detection in this script again. I found that if we want to detect the input of week - style dates, the principle is actually the same as that of digital - style date detection. It just needs to use a certain trick in the findstr command. So I immediately stayed up late to improve the date detection.
|
|
2006-7-1 01:21 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 63 楼』:
使用 LLM 解释/回答一下
从备份文件中恢复文件的功能还有问题,主要是对文件的取名问题,请暂时不要使用该功能。如果要使用,请在生成后的*_revert.bat文件中手动修改文件名,以免恢复出错。
There are still issues with the function of restoring files from backup files, mainly regarding the file naming problem. Please do not use this function for the time being. If you want to use it, manually modify the file name in the generated *_revert.bat file to avoid restoration errors.
|
|
2006-7-3 00:26 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 64 楼』:
使用 LLM 解释/回答一下
有谁愿意来把这个脚本再完善一下?主要是恢复备份这一段。
Who is willing to come and improve this script? Mainly the part of restoring the backup.
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2006-7-25 23:05 |
|
|
IceCrack
中级用户
   DOS之友
积分 332
发帖 168
注册 2005-10-6 来自 天涯
状态 离线
|
『第 65 楼』:
使用 LLM 解释/回答一下
我只能精神的支持你一下.我等尚须努力
I can only support you spiritually. We still need to work hard
|

测试环境: windows xp pro sp2 高手是这样炼成的:C:\WINDOWS\Help\ntcmds.chm |
|
2006-7-26 09:30 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 66 楼』:
使用 LLM 解释/回答一下
已经完善了对备份后的文件进行操作的部分,总体来看,这个脚本作为备份之用的基本功能已经具备了,剩下的工作主要就是查找bug、精简代码了。希望大家不要被大量的代码吓倒,都来测试一下吧。
The part of operating the backed-up files has been improved. Generally speaking, the basic functions of this script for backup purposes have been available. The remaining work mainly is to find bugs and streamline the code. I hope everyone is not intimidated by the large amount of code and all come to test it.
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2006-7-28 22:32 |
|
|
willsort
元老会员
         Batchinger
积分 4432
发帖 1512
注册 2002-10-18
状态 离线
|
『第 67 楼』:
使用 LLM 解释/回答一下
Re namejm:
问心而言,我仍然不赞同出于保护备份文件的考虑,而给程序附加过多的属性操作代码。因为与我们付出的代码和性能的高额代价相比,附加了各种属性的备份被人为修改和破坏的概率不会下降很多。这也是我无法考虑对restore模块作出更新和测试的主要理由。
也许只给目标目录加上属性是个折中的办法,效果与给所有目标加属性的方法相近,代价则要小得多。
当然,如果你坚持原来的看法,那么我提出一个对属性操作的:get_attrib段中for语句的改进建议:
for %%a in (a s h r) do echo %%i|findstr "%%a">nul && set a%%a=+%%a || set a%%a=
echo attrib !aa!!ah!!ar!!as!%%j >>"%batch_directory%\%name%_revert.bat"
Last edited by willsort on 2006-7-29 at 23:46 ]
Re: namejm:
To be honest, I still don't agree with adding too many attribute operation codes to the program for the sake of protecting backup files. Because compared with the high cost of code and performance we put in, the probability that backups with various attributes are artificially modified and damaged won't be reduced much. This is also the main reason why I can't consider updating and testing the restore module.
Maybe only adding attributes to the target directory is a compromise. The effect is similar to the method of adding attributes to all targets, but the cost is much lower.
Of course, if you insist on the original view, then I put forward an improvement suggestion for the for statement in the get_attrib segment of attribute operation:
for %%a in (a s h r) do echo %%i|findstr "%%a">nul && set a%%a=+%%a || set a%%a=
echo attrib !aa!!ah!!ar!!as!%%j >>"%batch_directory%\%name%_revert.bat"
Last edited by willsort on 2006-7-29 at 23:46 ]
|

※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得! |
|
2006-7-29 16:16 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 68 楼』:
使用 LLM 解释/回答一下
Re willsort:
当初之所以要给每个目标文件都加上“系统+只读”的属性,是想当用户意外地对其中的某个文件进行删除、重命名等操作的时候,系统会自动提醒是否真的要进行该操作,并没有指望能对付刻意的破坏。如果真要对付刻意的破坏的话,我倒是可以用md test..的方法来建立一个用常规方法无法访问和删除的文件夹来保存备份文件,只是考虑到有可能要对备份后的文件进行访问才放弃了这个刻毒的想法:)
如果只给最上层的目标文件夹加属性的话,防风险的能力比目前这个方案稍微弱一点,但是建立备份任务的效率得到了提升,有失有得啊。这个版本还是先保留目前的方案,用你精简后的代码替换我原来的那部分,先看看各位的意见再说吧。多谢你一直以来的关注和提供代码。
Last edited by namejm on 2006-8-1 at 01:17 ]
Re:
The reason why I initially added the "System + Read-only" attribute to each target file was to make the system automatically prompt whether the user really wants to perform operations like deletion or renaming when they accidentally do so for one of the files. It wasn't intended to deal with deliberate destruction. If I really wanted to deal with deliberate destruction, I could use the method of md test.. to create a folder that can't be accessed or deleted by conventional methods to store backup files. However, I gave up this malicious idea considering that there might be a need to access the backed-up files : )
If I only add attributes to the top-level target folder, the risk prevention ability is slightly weaker than the current plan, but the efficiency of setting up backup tasks is improved. There are both advantages and disadvantages. This version still keeps the current plan. Replace my original part with the simplified code you provided and see everyone's opinions first. Thanks for your continuous attention and code provision.
Last edited by namejm on 2006-8-1 at 01:17 ]
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2006-7-29 22:29 |
|
|
willsort
元老会员
         Batchinger
积分 4432
发帖 1512
注册 2002-10-18
状态 离线
|
『第 69 楼』:
使用 LLM 解释/回答一下
Re namejm:
发现了67楼代码一个显著和一个不显著的错误,已纠正67楼和顶楼代码。
第二句的attrib前缺少echo,%%j后应该添加一个空格,否则在%%j为单个数字时出错。
Re namejm:
Found one obvious and one less obvious error in the code at building 67. The code at building 67 and the top floor has been corrected.
There is a missing echo before attrib in the second sentence, and a space should be added after %%j; otherwise, it will error when %%j is a single digit.
|

※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得! |
|
2006-7-29 23:46 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 70 楼』:
使用 LLM 解释/回答一下
呵呵,willsort还真细心,连这么细微的地方都注意到了。在你的提示下,又发现了这段代码之前似乎还应该加上一句setlocal enabledelayedexpansion,以免延迟出错。
测试了一下目前的代码,发现了两个比较严重的问题,都是和xcopy /d /h /i /g /q /s /x /y "%source%" "%destination%" 这一句中的参数 /s 有关的:
1、当文件(而非文件夹)位于根目录下时,有时会无法复制成功,提示"不能执行周期性复制";
2、当要复制的文件之下的目录中存在同名文件的话,会把所有的同名文件复制;
解决问题1的关键,在于用xcopy的时候,要区分复制的是文件还是文件夹;
而问题2的解决却有点棘手:如果去掉参数/s,则只能复制指定文件夹的第一层文件,而不能复制文件夹下的所有自文件夹;如果不去掉参数/s的话,这个问题将无法避免。
Last edited by namejm on 2006-7-30 at 23:07 ]
Hehe, willsort is really meticulous, even noticing such a细微 place. Under your prompt, I also discovered that this code should have added a line setlocal enabledelayedexpansion before, to avoid delay errors.
Tested the current code and found two relatively serious problems, both related to the parameter /s in the line xcopy /d /h /i /g /q /s /x /y "%source%" "%destination%":
1. When a file (not a folder) is in the root directory, sometimes the copy fails and prompts "Cannot perform periodic copy";
2. If there are files with the same name in the directory under the file to be copied, all the same-named files will be copied;
The key to solving problem 1 is to distinguish whether to copy a file or a folder when using xcopy;
And the solution to problem 2 is a bit tricky: if the parameter /s is removed, only the first-level files of the specified folder can be copied, and the subfolders under the folder cannot be copied; if the parameter /s is not removed, this problem cannot be avoided.
Last edited by namejm on 2006-7-30 at 23:07 ]
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2006-7-30 14:40 |
|
|
chainliq
高级用户
    学无尽止
积分 635
发帖 244
注册 2006-4-15 来自 广西贵港
状态 离线
|
『第 71 楼』:
顶
使用 LLM 解释/回答一下
敢问版主能不能把修改好的整个程序发出来给我们大家共亨好吗?
May I ask the moderator if he can post the modified entire program for everyone to share?
|
|
2006-7-31 23:23 |
|
|
chainliq
高级用户
    学无尽止
积分 635
发帖 244
注册 2006-4-15 来自 广西贵港
状态 离线
|
『第 72 楼』:
使用 LLM 解释/回答一下
版主可以把整个修改好的程序放出来让大家代亨吗?
Moderators, can you release the entire modified program so that everyone can enjoy it?
|
|
2006-7-31 23:55 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 73 楼』:
使用 LLM 解释/回答一下
花了点时间,把70楼的两个问题解决了;再次测试的时候,发现willsort版主在67楼的 for %%a in (a s h r) 一句中"a"属性似乎有点多余,因为在测试中发现,任何一个文件都有"a"属性,可以不用考虑再用attrib来添加,此举可以在恢复备份后文件的批处理中节省大量的属性操作代码;顺带发现了几个错误,也一并修改。
Re chainliq:
从现在开始,将在顶楼提供bat和exe两种格式的文件下载,里面有简单的说明,多谢你的关注。
Last edited by namejm on 2006-8-1 at 01:38 ]
It took some time to solve the two problems on floor 70; when testing again, I found that in the line "for %%a in (a s h r) " by moderator willsort on floor 67, the "a" attribute seems a bit redundant because in testing it was found that any file has the "a" attribute, so there's no need to consider adding it with attrib again. This can save a lot of attribute operation code in the batch processing after restoring the backup; by the way, I also found and modified several errors.
Re chainliq:
From now on, both bat and exe format files will be provided for download at the top of the thread, with simple instructions. Thanks for your attention.
Last edited by namejm on 2006-8-1 at 01:38 ]
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2006-8-1 01:20 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 74 楼』:
使用 LLM 解释/回答一下
期待大家的测试。有什么问题请跟帖,需要大家共同参与。
Looking forward to everyone's testing. If you have any questions, please post a reply. It needs everyone's joint participation.
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2006-9-15 05:40 |
|
|
vkill
金牌会员
     
积分 4103
发帖 1744
注册 2006-1-20 来自 甘肃.临泽
状态 离线
|
『第 75 楼』:
使用 LLM 解释/回答一下
说实话还没有完整的看过这帖子,汗,回去看看学习学习
To be honest, I haven't read this whole post yet. Oh, I need to go back and read it to learn.
|
|
2006-9-15 06:13 |
|