简体   繁体   English

在NSIS中复制文件

[英]Copy Files in NSIS

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... 在...之前处理文档目录中的文件没有问题。

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. 使用FILE命令提取的文件是此处的问题。 The files consists of original files and copies of the same files (only with a different name). 这些文件由原始文件和相同文件的副本组成(仅使用不同的名称)。

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. 再次,我很抱歉这令人困惑,但这是我第一次与NSIS合作。 I need to extract ALL files. 我需要提取所有文件。

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 $0 $1 $OUTDIR\*
${While} $1 != ""
    ${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 $0 $1
${Loop}
FindClose $0
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. 这不会成为一种非常巧妙的方式,如果你能避免它,那就行了。

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. 我将使用我的初步解释:给定一个名为“Documents”的目录,其中包含一堆文件(它们被调用的内容,它们的内容无关紧要),您需要一个安装程序将文件复制到某些文件中输出目录。 I've created a test installer for this scenario here , and it works for me. 我在这里为这个场景创建了一个测试安装程序,它对我有用。 What am I missing in what you're after? 我在你所追求的内容中缺少什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM