> ## Documentation Index
> Fetch the complete documentation index at: https://developer.box.com/llms.txt
> Use this file to discover all available pages before exploring further.

# フォルダのコピー

export const MultiRelatedLinks = ({sections = []}) => {
  if (!sections || sections.length === 0) {
    return null;
  }
  return <div className="space-y-8">
      {sections.map((section, index) => <RelatedLinks key={index} title={section.title} items={section.items} />)}
    </div>;
};

export const RelatedLinks = ({title, items = []}) => {
  const getBadgeClass = badge => {
    if (!badge) return "badge-default";
    const badgeType = badge.toLowerCase().replace(/\s+/g, "-");
    return `badge-${badge === "ガイド" ? "guide" : badgeType}`;
  };
  if (!items || items.length === 0) {
    return null;
  }
  return <div className="my-8">
      {}
      <h3 className="text-sm font-bold uppercase tracking-wider mb-4">{title}</h3>

      {}
      <div className="flex flex-col gap-3">
        {items.map((item, index) => <a key={index} href={item.href} className="py-2 px-3 rounded related_link hover:bg-[#f2f2f2] dark:hover:bg-[#111827] flex items-center gap-3 group no-underline hover:no-underline border-b-0">
            {}
            <span className={`px-2 py-1 rounded-full text-xs font-semibold uppercase tracking-wide flex-shrink-0 ${getBadgeClass(item.badge)}`}>
              {item.badge}
            </span>

            {}
            <span className="text-base">{item.label}</span>
          </a>)}
      </div>
    </div>;
};

フォルダのコピーを宛先フォルダ内に作成します。

元のフォルダは変更されません。

Box上でフォルダをコピーするには、コピー先となる`parent`フォルダの`id`をAPIに渡す必要があります。

<CodeGroup>
  ```sh cURL theme={null}
  curl -i -X POST "https://api.box.com/2.0/folders/4353455/copy" \
       -H "authorization: Bearer <ACCESS_TOKEN>" \
       -H "content-type: application/json" \
       -d '{
         "parent": {
           "id": "345345"
         }
       }'
  ```

  ```typescript Node/TypeScript v10 theme={null}
  await client.folders.copyFolder(folderOrigin.id, {
    parent: { id: '0' } satisfies CopyFolderRequestBodyParentField,
    name: copiedFolderName,
  } satisfies CopyFolderRequestBody);
  ```

  ```python Python v10 theme={null}
  client.folders.copy_folder(
      folder_origin.id, CopyFolderParent(id="0"), name=copied_folder_name
  )
  ```

  ```cs .NET v10 theme={null}
  await client.Folders.CopyFolderAsync(folderId: folderOrigin.Id, requestBody: new CopyFolderRequestBody(parent: new CopyFolderRequestBodyParentField(id: "0")) { Name = copiedFolderName });
  ```

  ```swift Swift v10 theme={null}
  try await client.folders.copyFolder(folderId: folderOrigin.id, requestBody: CopyFolderRequestBody(parent: CopyFolderRequestBodyParentField(id: "0"), name: copiedFolderName))
  ```

  ```java Java v10 theme={null}
  client.getFolders().copyFolder(folderOrigin.getId(), new CopyFolderRequestBody.Builder(new CopyFolderRequestBodyParentField("0")).name(copiedFolderName).build())
  ```

  ```java Java v5 theme={null}
  BoxFolder folder = new BoxFolder(api, "id1");
  BoxFolder destination = new BoxFolder(api, "id2");
  folder.copy(destination);
  ```

  ```python Python v4 theme={null}
  folder_id = '22222'
  destination_folder_id = '44444'

  folder_to_copy = client.folder(folder_id)
  destination_folder = client.folder(destination_folder_id)

  folder_copy = folder_to_copy.copy(parent_folder=destination_folder)
  print(f'Folder "{folder_copy.name}" has been copied into folder "{folder_copy.parent.name}"')
  ```

  ```cs .NET v6 theme={null}
  // Copy folder 11111 into folder 22222
  var requestParams = new BoxFolderRequest()
  {
      Id = "11111",
      Parent = new BoxRequestEntity()
      {
          Id = "22222"
      }
  };
  BoxFolder folderCopy = await client.FoldersManager.CopyAsync(requestParams);
  ```

  ```javascript Node v4 theme={null}
  client.folders.copy('11111', '22222')
      .then(folderCopy => {
         /* folderCopy -> {
              type: 'folder',
              id: '1234567',
              sequence_id: '0',
              etag: '0',
              name: 'Pictures from 2017',
              created_at: '2012-12-12T10:53:43-08:00',
              modified_at: '2012-12-12T11:15:04-08:00',
              description: 'Some pictures I took',
              size: 629644,
              path_collection: 
              { total_count: 1,
                  entries: 
                  [ { type: 'folder',
                      id: '0',
                      sequence_id: null,
                      etag: null,
                      name: 'All Files' },
                    { type: 'folder',
                      id: '22222',
                      sequence_id: '3',
                      etag: '3',
                      name: 'Archives' } ] },
              created_by: 
              { type: 'user',
                  id: '22222',
                  name: 'Example User'
                  login: 'user@example.com' },
              modified_by: 
              { type: 'user',
                  id: '22222',
                  name: 'Example User',
                  login: 'user@example.com' },
              owned_by: 
              { type: 'user',
                  id: '22222',
                  name: 'Example User',
                  login: 'user@example.com' },
              shared_link: null,
              parent: 
              { type: 'folder',
                  id: '22222',
                  sequence_id: '3',
                  etag: '3',
                  name: 'Archives' },
              item_status: 'active',
              item_collection: 
              { total_count: 1,
                  entries: 
                  [ { type: 'file',
                      id: '44444',
                      sequence_id: '0',
                      etag: '0',
                      sha1: '134b65991ed521fcfe4724b7d814ab8ded5185dc',
                      name: 'tigers.jpeg' } ],
                  offset: 0,
                  limit: 100 } }
          */
      });
  ```
</CodeGroup>

オプションで、新しいフォルダに別の名前を付けることもできます。

<Note>
  **名前に関する制約事項**

  フォルダ名にはいくつかの制限があります。印字不可能なASCII文字、スラッシュ、バックスラッシュ (`/`、`\`) を含む名前のほか、末尾にスペースを含む名前は禁止されています。

  また、`.`および`..`は予約済みの名前であるため、使用できません。
</Note>

## 非同期コピー

コピーされるフォルダに含まれる項目が500個以下の場合は、APIコールと同時にコピーが実行されます。コールはコピー操作が完了するまで復帰しません。

コピー元のフォルダに500個を超える項目が含まれる場合は、非同期的にコピー操作が実行され、APIコールはコピー操作が完了していなくても直ちに復帰します。現時点では、コピー操作がいつ終了したのかを確認するAPIはありません。

## フォルダのロック

この操作の進行中は、ファイルツリーの一部がロックされます。ロックされるのは、主に元のフォルダとその子孫フォルダ、および宛先フォルダです。

操作の進行中は、ロックされているどのフォルダに対しても、他の移動、コピー、削除、または復元操作を実行できません。最も重要な点は、同じフォルダをフォルダツリーの2つの異なる部分に同時にコピーすることはできないということです。

## メタデータ

宛先フォルダのいずれかの親フォルダにメタデータカスケードポリシーが適用されている場合は、メタデータカスケード操作が非同期的に開始されます。

現時点では、この操作がいつ終了したのかを確認するAPIはありません。

<RelatedLinks
  title="関連するAPI"
  items={[
{ label: translate("Copy folder"), href: "/reference/post-folders-id-copy", badge: "POST" }
]}
/>

<RelatedLinks
  title="関連するガイド"
  items={[
{ label: translate("Create Folder"), href: "/guides/folders/single/create", badge: "GUIDE" },
{ label: translate("Delete Folder"), href: "/guides/folders/single/delete", badge: "GUIDE" }
]}
/>
