简体   繁体   English

如何通过查看文件名的一部分来移动文件

[英]How do I move files by looking at part of a file name

My web application creates multiple image thumbnail files when users upload images. 我的Web应用程序在用户上传图像时创建多个图像缩略图文件

I want to separate original images and thumbnail images. 我想分离原始图像和缩略图。 Thumbnail images contain 'crop-smart' in their file name. 缩略图图像的文件名中包含“crop-smart”。

For example, original image is watermelon.jpg, then thumbnail's name is watermelon_jpg_120x120_crop-smart.jpg. 例如,原始图像是watermelon.jpg,然后缩略图的名称是watermelon_jpg_120x120_crop-smart.jpg。

How do I find by say 'crop-smart' and either move them to the different folder or delete them? 如何找到'crop-smart'并将它们移动到不同的文件夹或删除它们?

Standard file globbing will do this, the exact details may vary depending out which shell you are running but for your exact problem, it should be the same: 标准文件通配符会执行此操作,具体细节可能会有所不同,具体取决于您运行的是哪个shell但是对于您确切的问题,它应该是相同的:

mv -- *_crop-smart.jpg /path/to/new/folder/

(This will also work if you have spaces in the filename) (如果文件名中有空格,这也可以工作)

Note the -- signals to mv that no more option switches will follow, so even if filenames look like options, mv won't get confused. 注意 --mv发出信号,表示不再有选项开关,因此即使文件名看起来像选项, mv也不会混淆。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM