如何使一個檔案同時出現在多個資料夾中?

如果您為工作設定了大量資料夾,並且在工作日需要在所有資料夾中使用相同的指令碼檔案,那麼除了大量複製和貼上之外,最簡單的方法是什麼?今天的超級使用者問答帖子為沮喪的讀者提供了一些有用的答案和建議。...

如何使一個檔案同時出現在多個資料夾中?

如果您為工作設定了大量資料夾,並且在工作日需要在所有資料夾中使用相同的指令碼檔案,那麼除了大量複製和貼上之外,最簡單的方法是什麼?今天的超級使用者問答帖子為沮喪的讀者提供了一些有用的答案和建議。

今天的問答環節是由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
  • 閱讀 ( 32 )
  • 分類:網際網路

你可能感興趣的文章

8谷歌驅動android功能你應該使用

... 如何使用谷歌硬碟?你有什麼我們沒有列出的最喜歡的功能嗎?請在下面的評論中與我們分享您的建議。 ...

  • 發佈於 2021-03-12 15:36
  • 閲讀 ( 46 )

如何在iphone和ipad上使用ios11的新檔案應用程式

...文件、儲存檔案、與其他人協作以及匯出文件。下面介紹如何在iOS 11中使用新的檔案應用程式。 ...

  • 發佈於 2021-03-13 02:03
  • 閲讀 ( 49 )

為mac使用者提供7個省時的開啟和儲存對話方塊提示

... 每次我想在開啟一個檔案之前預覽它,我都會導航到它在Finder中的位置,以使用快速查詢功能。我從來沒有想過,我可以預覽檔案,因為我開啟他們,即從開啟對話方塊。事後看來,這似...

  • 發佈於 2021-03-15 01:13
  • 閲讀 ( 39 )

6個預設的windows檔案和資料夾,您不應觸控

...)。在此期間,應用程式在ProgramFiles資料夾中為自己建立一個條目,添加註冊表值,並執行它需要在系統上正常工作的其他任務。 ...

  • 發佈於 2021-03-15 10:38
  • 閲讀 ( 49 )

用於檔案管理的10個最佳windows檔案資源管理器副檔名

...動圖示上拖放檔案或資料夾以開始處理它們。您可以定義如何按名稱、大小、日期、屬性篩選檔案,並關聯要執行的21個可用操作之一。它支援上傳、重新命名、加密、壓縮、更改屬性等操作。 ...

  • 發佈於 2021-03-22 02:04
  • 閲讀 ( 53 )

在Windows10上建立zip檔案的6種簡單方法

... 以下是如何查詢和使用此選項: ...

  • 發佈於 2021-03-28 11:34
  • 閲讀 ( 39 )

如何在mac上製作zip檔案

... 本指南將介紹什麼是ZIP檔案,以及如何在macOS中建立ZIP檔案。 ...

  • 發佈於 2021-03-28 16:40
  • 閲讀 ( 66 )

如何在mac上壓縮和解壓檔案和資料夾

...用程式,而是一個深入整合到Finder應用程式中的功能。 如何在mac上壓縮檔案和資料夾 要開始,請開啟“Finder”應用程式,找到要壓縮的檔案或資料夾。如果要選擇多個檔案,請在選擇檔案時按住Command鍵。 一旦你做了選擇,右...

  • 發佈於 2021-04-02 03:45
  • 閲讀 ( 41 )

如何在windows 10上覆制或移動檔案和資料夾

...方法。我們將向您展示檔案資源管理器的所有技巧,以及如何在命令提示符和PowerShell中使用它們。您甚至可以將“複製到”和“移動到”新增到檔案資源管理器的上下文選單中。 在Windows 10中複製檔案或資料夾時,所選專案將被...

  • 發佈於 2021-04-02 06:41
  • 閲讀 ( 94 )

如何在Windows10桌面上建立不可見資料夾

...每次只需增加資料夾名稱中不可見空格的數量。 相關:如何隱藏每個作業系統上的檔案和資料夾 這是不安全的,可能是小車 顯然,這不是一種隱藏檔案的安全方法。任何人都可以透過系統搜尋找到不可見資料夾的內容。有人...

  • 發佈於 2021-04-02 11:16
  • 閲讀 ( 56 )
ulqzkskrj
ulqzkskrj

0 篇文章

作家榜

  1. admin 0 文章
  2. 孫小欽 0 文章
  3. JVhby0 0 文章
  4. fvpvzrr 0 文章
  5. 0sus8kksc 0 文章
  6. zsfn1903 0 文章
  7. w91395898 0 文章
  8. SuperQueen123 0 文章

相關推薦