windows 在 NSIS 中复制文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3711060/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Copy Files in NSIS
提问by Silly Rabbit
I am using the following command to copy files.
我正在使用以下命令复制文件。
After setting output path...
设置输出路径后...
File "Documents\*"
This action works flawlessly. There are no issues coping the files in the Documents directory until...
这个动作完美无缺。处理 Documents 目录中的文件没有问题,直到...
if there is a copy of an existing file (with a different name) in the directory only the first instance of the file gets copied regardless of name.
如果目录中有现有文件的副本(具有不同的名称),则无论名称如何,只会复制该文件的第一个实例。
How do I make it so it will copy ALL files regardless if they are copies of other files?
我该如何制作它才能复制所有文件,而不管它们是否是其他文件的副本?
Correction/better explanation (maybe)
更正/更好的解释(也许)
I apologize for the confusion. Allow me to try to restate the problem. The files being extracted by using the FILE command is the issue here. The files consists of original files and copies of the same files (only with a different name).
对于造成的混乱,我深表歉意。请允许我尝试重述这个问题。使用 FILE 命令提取的文件是这里的问题。文件由原始文件和相同文件的副本(仅名称不同)组成。
example: MyDocument.txt and copyOfMyDocument.txt and so on..
例如:MyDocument.txt 和 copyOfMyDocument.txt 等等..
When the File command is applied, in order to be extract the files to the current output path, only the first instance of the file is extracted (either the copy or the original... but not both). Again, I am sorry for the confusing but this is the first time I've had to work with NSIS. I need to extract ALL files.
当应用 File 命令时,为了将文件提取到当前输出路径,只提取文件的第一个实例(副本或原始...但不是两者)。再次,我很抱歉造成混乱,但这是我第一次不得不与 NSIS 合作。我需要提取所有文件。
回答by Chris Morgan
The easiest way to do this will be to put it in a different directory which you've created. Then, if you need to worry about renaming (as the commentators have noted your question doesn't make much sense), you can attack it file by file.
最简单的方法是将它放在您创建的不同目录中。然后,如果您需要担心重命名(因为评论员已经指出您的问题没有多大意义),您可以逐个文件攻击它。
# Extract the files to a directory which can't exist beforehand
CreateDirectory $PLUGINSDIR\extracting
SetOutPath $PLUGINSDIR\extracting
File Documents\*
# Now go through file by file
FindFirst ##代码## $OUTDIR\*
${While} != ""
${If} ${FileExists} $DOCUMENTS$1
# This still isn't infallible, of course.
Rename $DOCUMENTS$1 $DOCUMENTS$1.local-backup
${EndIf}
Rename $OUTDIR$1 $DOCUMENTS$1
FindNext ##代码##
${Loop}
FindClose ##代码##
SetOutPath $INSTDIR # Or somewhere else
RMDir $PLUGINSDIR\extracting
(Note that that's using LogicLib.)
(请注意,这是使用 LogicLib。)
This doesn't become a very neat way of doing it though and if you can avoid it, do.
但是,这并不是一种非常巧妙的方法,如果可以避免,那就去做。
回答by fakeleft
i thought i understood what you were after, until i started reading the responses; i'll go with my initial interpretation: given a directory named "Documents", with a bunch of files in it (what they're called, and their contents should not matter), you want an installer that will copy the files into some output directory. I've created a test installer for this scenario here, and it works for me. What am I missing in what you're after?
我以为我明白你在追求什么,直到我开始阅读回复;我会按照我的初步解释:给定一个名为“Documents”的目录,里面有一堆文件(它们叫什么,它们的内容不重要),你需要一个安装程序,将文件复制到一些输出目录。我在这里为这个场景创建了一个测试安装程序,它对我有用。你所追求的我错过了什么?