0

i have a batch script and it has a variable '%4' and it's random file names but sometimes it has names like:

some.thing.here.mp3
some.other.thing.mp3
and.another.mp3
and.some.file.mp3

and i want to have it goto EOF if the file name contains the word 'some' (so all but the third file..)

i have this so far but it's not working

IF /I "%4"=="some" GOTO EOF
steve
  • 225
  • 1
  • 3
  • 7

1 Answers1

0

Try this:

echo "%4" | find /i "some" >nul 2>&1 && GOTO:EOF
Endoro
  • 37,015
  • 8
  • 50
  • 63
  • as a side question can i include multiple words? like "someORotherORfoobar"? – steve Apr 29 '13 at 11:53
  • Yes, but `find` finds every individual word. – Endoro Apr 29 '13 at 12:03
  • So put the search pattern in a variable `set "var=some"` `echo "%4" | find /i "%var%"` – Endoro Apr 29 '13 at 12:08
  • Example: `echo "%4" | findstr /i "some test"`, for more words you should use `findstr`. – Endoro Apr 29 '13 at 18:18
  • i've come across a problem with this i'm using the below code to find the word 'test' in %4 (which is normally file names like in my first post) but when changing the code to %5 (which is a folders full path eg. "c:\temp\some.test.folder") it's not picking it up.. will this code not work for folders like it does for files? echo "%~5" | find /i "test" >nul 2>&1 && GOTO end – steve May 11 '13 at 18:23
  • hmm my last comment is all screwed up.. i can't use line breaks or indents for the code? :/ – steve May 11 '13 at 18:28
  • Yes, you can use indents. What do you mean with line breaks? %5 can't contain a line break .... – Endoro May 11 '13 at 18:42
  • when i said 'i can't use line breaks or indents for the code' i mean the COMMENT i made NOT my code in question (like for example i can't press enter for a new line as it'll just save the comment) and nor can i format my code but again my problem persists.. here's a readable version: http://tinyurl.com/blt79sm – steve May 11 '13 at 21:13
  • after a bit of testing yes the command is working it's the next part involving the move command that is failing as i'm getting an 'access denied' error... think it's best to make a new thread about this.. thanks for the help :) – steve May 11 '13 at 21:44
  • No, it works for me, please see [here](http://www.imagebanana.com/view/wnw0eba8/snap112.gif) and [here](http://pastebin.com/JCqzeB30). And yes, in comments you can't make "enter", you can "shift-enter", but it will not be seen. – Endoro May 11 '13 at 21:46
  • yes i know that's working but again the problem is with the next part of the script: http://tinyurl.com/bld488u (i tried to make a new thread about this but it won't let me) – steve May 11 '13 at 22:07
  • made a topic here: http://stackoverflow.com/questions/16502283/how-do-i-fix-access-denied-with-the-move-command-in-windows-7 – steve May 11 '13 at 22:25