在 NSIS 中复制文件

发布于 2024-09-19 10:58:09 字数 496 浏览 2 评论 0原文

我正在使用以下命令来复制文件。

设置输出路径后...

File "Documents\*"

此操作完美运行。复制 Documents 目录中的文件不会出现任何问题,直到...

如果目录中存在现有文件(具有不同名称)的副本,则无论名称如何,仅复制该文件的第一个实例。

我该如何制作才能复制所有文件,无论它们是否是其他文件的副本?

更正/更好的解释(也许)

我对造成的混乱表示歉意。请允许我尝试重述这个问题。使用 FILE 命令提取的文件是这里的问题。这些文件由原始文件和相同文件的副本(仅名称不同)组成。

例如:MyDocument.txt 和 copyOfMyDocument.txt 等。

应用 File 命令时,为了将文件提取到当前输出路径,仅提取文件的第一个实例(副本或原始文件) ...但不是两者都)。再次,对于造成的混乱,我深表歉意,但这是我第一次与 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. 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..

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

对你再特殊 2024-09-26 10:58:09

最简单的方法是将其放在您创建的不同目录中。然后,如果您需要担心重命名(正如评论员指出您的问题没有多大意义),您可以逐个文件地攻击它。

# 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

(请注意,这是使用 LogicLib。)

但这并不是一种非常简洁的方法,如果您可以避免它,那就这样做。

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.)

This doesn't become a very neat way of doing it though and if you can avoid it, do.

囍笑 2024-09-26 10:58:09

我以为我明白你在追求什么,直到我开始阅读回复;我将采用我最初的解释:给定一个名为“Documents”的目录,其中包含一堆文件(它们的名称,它们的内容不重要),您需要一个安装程序将文件复制到某些文件中输出目录。我已经在此处为此场景创建了一个测试安装程序,它对我有用。我在你追求的东西中缺少什么?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文