Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

16
  • @ksuzy31 Does changing to echo mv -v "$keyword" "$destination" do, what you want? Without the -i option, the mv command doesn't prompt before overwrite a file. Commented Nov 6, 2017 at 20:53
  • Or Hi, what if I had apple02-05group-AP05 and have multiple hyphens and i'm still just looking for if it has keyword, AP, put it in Fruit folder and then make a subfolder with the name apple02-05group-AP05 with this inside it Commented Nov 6, 2017 at 21:30
  • @ksuzy31 I don't know. I tested both scripts on your original filenames (Apple-AP01, Apple-AP02, Banana-AP05, Chocolate-RS33) and they were working. If filenames differs from original examples, than it needed to tailor scripts for them. Commented Nov 6, 2017 at 21:32
  • @ksuzy31 apple02-05group-AP05 this kind filenames will be a problem, because the [A-Za-z]+-[A-Z]+[0-9]+ regex mathes only to Apple-AP01 kind. The [A-Za-z]+-[A-Z]+[0-9]+ means - one or more letters, then dash, then one or more capital letters, then one or more digits. So, another type of filenames wouldn't conform to this pattern. Commented Nov 6, 2017 at 21:35
  • hmm I see. Do you think there's some work around with the multiple hyphens because that's kind of what I have now. BTW thank you for above. You were right, I had the name wrong. But now I have to do these multiple hyphens but what if it was all caps like APPLE02-05GROUP-AP05. Do you think you could help me with a script that would put that into Fruit folder. and like CHOCOLATE-02GROUP-RS33 into Sweet folder. Commented Nov 6, 2017 at 21:39