简体   繁体   中英

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.

I want to separate original images and thumbnail images. Thumbnail images contain 'crop-smart' in their file name.

For example, original image is watermelon.jpg, then thumbnail's name is 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?

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:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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