根据子文件夹名称拆分文件夹

发布于 2025-01-16 19:36:34 字数 697 浏览 6 评论 0原文

对于一个网站,我有很多包含相同子文件夹(图像+缩略图)的文件夹。所有这些都包含“images”文件夹,但并非所有都包含“thumbnails”文件夹。

/directory1
   /folder1
      /images
      /thumbnails
   /folder2
      /images
   /folder3
      /images
      /thumbnails
   /folderA
      /images
   /folderB
      /images
      /thumbnails

我想将缩略图移到另一个目录中,因此基本上将文件夹结构分开:

/directory1
   /folder1
      /images
   /folder2
      /images
   /folder3
      /images
   /folderA
      /images
   /folderB
      /images

/directory2
   /folder1
      /thumbnails
   /folder3
      /thumbnails
   /folderB
      /thumbnails

是否有一种简单/快速的方法可以做到这一点?

所有文件夹/文件都存储在 Synology NAS 上,我可以通过 Windows PC 访问它们。

For a website I have a lot of folders containing the same subfolders (images + thumbnails). All of them contain the "images" folder, but not all of them contain "thumbnails" folder.

/directory1
   /folder1
      /images
      /thumbnails
   /folder2
      /images
   /folder3
      /images
      /thumbnails
   /folderA
      /images
   /folderB
      /images
      /thumbnails

I would like to move the thumbnails into another directory, so basically separate the folderstructure:

/directory1
   /folder1
      /images
   /folder2
      /images
   /folder3
      /images
   /folderA
      /images
   /folderB
      /images

/directory2
   /folder1
      /thumbnails
   /folder3
      /thumbnails
   /folderB
      /thumbnails

Is there an easy/fast way to do this?

All folders/files are stored on a Synology NAS and I can access them via a Windows PC.

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

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

发布评论

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

评论(1

丢了幸福的猪 2025-01-23 19:36:34

最后我用一些 php 脚本解决了这个问题。使用的主要函数是:

  1. ini_set('max_execution_time', 10800); 必要时为其提供一些运行
  2. scandir 来检查目录中的所有文件和文件夹
  3. mkdir 在别处创建新目录
  4. rename 将文件或文件夹移动到新目录

起初我担心 rename 功能会复制文件/文件夹并删除之后再处理旧的,这会花费很多时间。但事实并非如此,它移动文件/文件夹并且运行速度实际上非常快。

In the end I resolved it with a little php-script. The main functions used are:

  1. ini_set('max_execution_time', 10800); to give it some to run if necessary
  2. scandir to check all files and folders within a directory
  3. mkdir to create a new directory elsewhere
  4. rename to move the file or folder to the new directory

At first I was concerned that the rename function would copy the files/folders and delete the old ones afterwards, which would take a lot of time. But this is not the case, it moves the files/folders and it ran actually very fast.

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