如何使一个文件同时出现在多个文件夹中?

如果您为工作设置了大量文件夹,并且在工作日需要在所有文件夹中使用相同的脚本文件,那么除了大量复制和粘贴之外,最简单的方法是什么?今天的超级用户问答帖子为沮丧的读者提供了一些有用的答案和建议。...

如何使一个文件同时出现在多个文件夹中?

如果您为工作设置了大量文件夹,并且在工作日需要在所有文件夹中使用相同的脚本文件,那么除了大量复制和粘贴之外,最简单的方法是什么?今天的超级用户问答帖子为沮丧的读者提供了一些有用的答案和建议。

今天的问答环节是由SuperUser提供的,SuperUser是Stack Exchange的一个分支,是一个由社区驱动的问答网站分组。

由csaveanu(Flickr)提供的屏幕截图。

问题

超级用户阅读器Elliot正在寻找让同一个文件同时出现在多个文件夹中的最佳方法:

I have 50+ folders, each of which contains a large amount of data that needs to be processed. All of them are processed using the same exact code, utilizing os.path.dirname(os.path.realpath(file)) to get the directory in which the python script is located so there is no manual editing needed by the user, they just need to double click.

I need the script to appear as if it is in each folder while actually being in only one place so that I can edit it once, then when it is run from any of these locati*** have the folder path be correct. The alternative is editing the master and then pasting it one folder at a time through all 50+ folders every time I update the code, which is very tedious and error prone. On Linux, I could set this up with a symbolic link, but I cannot figure out a way to do this with Windows.

Alternatively, a way to paste the file into all the target directories at once, instead of one at a time, would accomplish the same goal.

有没有办法做到这一点,而不是复制和粘贴脚本文件一次一个文件夹?

答案

超级用户贡献者gronostaj为我们提供了以下答案:

You need a Symbolic Link or a Hard Link.

Symbolic Links (or Symlinks for short) are quite similar to shortcuts: there is one actual file and multiple references (Symlinks) to it. They even have that little arrow on the ic***. Unlike shortcuts, Symlinks can have any extension.

Hard Links bind a file on a hard drive to a location in the directory tree. Each file has at least one Hard Link, otherwise it would not exist in any directory. If a file has multiple Hard Links, the original one cannot be distinguished from the others and the file physically exists in only one location.

Both Have Their Limitati***:

  • Some software does not play nicely with Symlinks.
  • Deleting the original file leaves all of its Symlinks broken.
  • You cannot Hard Link folders (but you can create a Directory Junction if a Symlink is not enough).
  • Creating cross-partition Hard Links is impossible.

Symlinks are usually sufficient.

To Create a Symlink or a Hard Link:

1. Launch a privileged command line: Press the Windows Key, type cmd, then press Ctrl+Shift+Enter.

2. Issue the mklink command:

  • mklink link_name link_target for a file Symlink
  • mklink /d link_name link_target for a folder Symlink
  • mklink /h link_name link_target for a file Hard Link
  • mklink /j link_name link_target for a Directory Junction

有什么要补充的解释吗?在评论中发出声音。想从其他精通技术的Stack Exchange用户那里了解更多答案吗?在这里查看完整的讨论主题。

  • 发表于 2021-04-10 21:32
  • 阅读 ( 166 )
  • 分类:互联网

你可能感兴趣的文章

adobe acrobat pro dc管理PDF迷你指南

...obatprodc有效地创建和编辑pdf所需的一切知识。您还将学习如何对PDF进行数字签名,如何比较不同的PDF文档,等等。 ...

  • 发布于 2021-03-12 12:02
  • 阅读 ( 233 )

如何批量重命名mac上的多个文件

...使用重命名工具,请在Finder中打开包含要重命名的文件的文件夹,然后选择它们。 ...

  • 发布于 2021-03-13 07:03
  • 阅读 ( 401 )

如何合并microsoft outlook pst文件:5种简单方法

... 例如,“合并PST文件”允许您按文件夹类型筛选PST合并,例如仅从不同的PST文件导**系人或日历文件夹。 ...

  • 发布于 2021-03-21 15:26
  • 阅读 ( 498 )

为您的mac电脑提供8个省时的自动化工作流程

... 从“应用程序”文件夹打开Automator时,系统会要求您选择要创建的文档类型。请看我们的自动机简介,了解每种类型和示例工作流的说明。 ...

  • 发布于 2021-03-22 08:58
  • 阅读 ( 354 )

如何在mac上的safari中管理书签和收藏夹:完整指南

...很多网站添加书签的时候。因此,尽早开始将书签组织到文件夹中是个好主意,这样可以控制它们。但组织起来永远不嫌晚。如果你有一大堆杂乱无章的书签,可能需要一段时间。 ...

  • 发布于 2021-03-24 18:18
  • 阅读 ( 788 )

如何在没有传真机的情况下通过计算机在线发送传真

... 同时,可以在“已发送”文件夹中查看已发送的传真,并从收件箱中提取发送给您的文档。记住,只打印出那些你真正需要一份实体拷贝的文档! ...

  • 发布于 2021-03-30 08:53
  • 阅读 ( 210 )

如何在Windows10上压缩(和解压)文件

...何在Windows10上压缩和解压文件。 如何创建zip文件(压缩文件夹) 首先,打开“文件资源管理器”,找到要压缩并合并到Zip文件中的文件或文件夹。Windows将Zip文件称为“压缩文件夹”,因此在本例中,这些术语可以互换。 我们...

  • 发布于 2021-04-02 06:33
  • 阅读 ( 177 )

如何在linux上使用grep命令

...符号链接。我们在这个目录中有一个符号链接,叫做logs文件夹。它指向/home/dave/logs。 ls -l logs-folder 让我们用-R(递归解引用)选项重复上一次搜索: grep -R -i memfree . 符号链接后面跟着,它指向的目录也会被grep搜索。 搜索整...

  • 发布于 2021-04-02 17:23
  • 阅读 ( 165 )

如何合并多个google drive和google photos帐户

...。 下一步,您可以从PC中选择要备份到Google Drive帐户的文件夹。默认情况下,Google备份和同步将同步Windows上的桌面、文档和图片文件夹。如果你不介意的话,让他们检查一下。否则,取消选中。 为了简化操作,请在PC上创建一...

  • 发布于 2021-04-03 02:55
  • 阅读 ( 269 )

如何将powerpoint对象保存为图片

...存为单个图像 让我们回到我们的示例幻灯片,看看它是如何完成的。 首先,我们需要选择要保存为图像的对象。要在幻灯片中选择多个对象,请在按住Ctrl键的同时单击每个对象。在本例幻灯片中,我们有四个对象,我们将选择...

  • 发布于 2021-04-04 00:33
  • 阅读 ( 151 )
ulqzkskrj
ulqzkskrj

0 篇文章

相关推荐