Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Im trying to make a find regex script so i automaticly can copy files to specific directory.

find . -regex "*test.*s01e([0-9][0-9]).*" -exec cp {} /storage/tv/test/s01/ \;

Made this script, dont get any errors but it doesnt list anything. Also tried to just run the command in terminal and still the command runs without error but doesnt list anything. Is there something wrong i have done or is this something that's not easy to get to work?

share|improve this question

GNU findutils uses Emacs style regex, so out of box, this should suffice:

find . -regex '.*test.s01e[0-9][0-9]' -exec cp {} /storage/tv/test/s01 \;
share|improve this answer
    
Thanks for the reply, but it does not seem to work. If i use find . -name test.s01e03* works fine, but then i need to specify the filename instead of searching for test.s01([0-9][0-9]) with regex. but this simple regex script works like a charm, but cant get the other one to work. find -regex ".*(jpg\|png)" – stone Jan 20 '15 at 13:39
    
In that case, I don't really follow what you're trying to do ... Is your intent to copy (for example) s01e01 file to /storage/tv/test/s01/ as 01? – Priit Jan 20 '15 at 13:41

Found the solution

find . -regex '.*test.*s01e[0-9][0-9].*720p.*x264.*' -exec cp {} /storage/tv/test/s01/ \;
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.