将网络文件夹中具有不同名称的FTP文件夹上的图片重命名为1个文件(替代) [英] Renaming Pictures on a FTP Folder with different Names to 1 File (Override) for a Webcam Feed

查看:108
本文介绍了将网络文件夹中具有不同名称的FTP文件夹上的图片重命名为1个文件(替代)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的一个客户遇到了以下问题:

A Client of me had the follwing Problem:

他有一个可将图片上传到FTP文件夹的网络摄像头.

He has a Webcam that Uploads Pictures to a FTP Folder.

不幸的是,网络摄像头确实单独上传了每个文件(Webcam_Eglisauxxxxxx.jpg) xxxxx代表网络摄像头中的时间戳.没有办法让网络摄像头独自覆盖最新文件:(

Unfortunaly the Webcam does Upload each File seperatly (Webcam_Eglisauxxxxxx.jpg) xxxxx stands for a Timestamp from the Webcam. There is no Way to achive that the Webcam by herself just overrides the latest file :(

现在,我需要一个php脚本来检查该目录中的新文件,并将其重命名为给定的名称. (Webcam_Eglisau_Image.jpg)

Now i Need a php script to check against new Files in this Directory and rename it to a given Name. (Webcam_Eglisau_Image.jpg)

我知道这需要重命名功能,但是我不知道如何在文件中搜索未知名称(xxxxxx).

I know that this Need the rename function but i have no Idea how i can search for a not know Name (the xxxxxx) in the File.

.php文件将与图片位于同一目录...

The .php File will be located in the same Dir as the Pictures...

有什么想法吗?

我想在执行Cron Job之后运行此脚本:)

I would like to run this script after with a Cron Job :)

谢谢

推荐答案

您可以使用

$fileList = glob('Webcam_Eglisau*.jpg');
var_dump($fileList);

它为您提供所有文件Webcam_Eglisau * .jpg 然后,您可以重命名一个名为xxxxxxx(最新的版本)

It gives you all Files Webcam_Eglisau * .jpg Then you can rename the one which is called xxxxxxx (the newest)

更新:

foreach (glob("Webcam_Eglisau*.jpg") as $filename) {
  echo "Renaming " . $filename . " now.</br>";
  $uniqid = uniqid();
  if(file_exists($filename)) {
    rename($filename, "Webcam_Eglisau_" . $uniqid . ".jpg");
    echo $filename . " is now Webcam_Eglisau_" . $uniqid . ".jpg</br>";
  }
}

这篇关于将网络文件夹中具有不同名称的FTP文件夹上的图片重命名为1个文件(替代)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆