| 1. |
Solve : if here are more than (..) file? |
|
Answer» hi dir "*.swf" | find /i "file" and it worked but below script is not working i dont know why Quote for /f "tokens=1 delims= " %%a in ('dir *.swf ^| find "File(s)"') do set var=%%aI gave you the code for when it is greater than 6 and the code for the FOR loop. You have refused to use both. Why? There is no such thing as a MORE compare operator. Open up a command prompt and type: if /? dear Squashman its too complicated for me ! CANT you do the rest believe it or not if i could figure it out myself i would have done that and something elas i tried this script and it did nothing why ? there were just 2 swf files !! Quote for /f "tokens=1 delims= " %%G in ('dir *.swf ^| findstr /R /C:"File(s) .* bytes$"') do (please helpYou don't need a :EOF label to go to. GOTO :EOF is the same as using the exit command. Your goto for step 2 does not work because your label has 2 colons in front of it.ok now i tried this one and it worked but it looks ugly to me can someone make it better or fix the problems? working script Quote for /f "tokens=1 delims= " %%G in ('dir *.swf ^| findstr /R /C:"File(s) .* bytes$"') do ( problems= 1-if some ( jpg or flv ) files are exited in sub-directories they cant be find or copy 2- script is not sharp enough and is not working exactly(SOMETIMES good sometimes bad !)ok my other topic closed so i came here but to me its a different question !! ==================== here is my topic please read it and if you can help hi i have a problem with my batch script i want to DIR and check to see if these files are exist or not Quote myflash.rar source.fla newfile.swf movie.flv *.reg if they are exist (mostly in source folder) go to finish and end but if there are not at least one of those files exist move everything from source folder to extra folder important= 1-its not Necessary for existence of all of those files at the same time 2-but at least one of those should be in source folder 3-if there were not at lease one of those files move everything from source folder to extra folder my script is here but i dont know why its not working and how should i fix it Quote Quote @echo off & setLocal EnableDelayedExpansion1) You need to use the /B switch with the DIR command 2) don't use a space as a delimiter. 3) move your closing parenthesis after your IF statements. 4) You should put quotes around your variable names when dealing with file names and directory paths.dear Squashman i tried what you said or at least what i got from your answer but it didn't worked Quote 1) You need to use the /B switch with the DIR commandyou man dir/s/B i tried this one too dir/B Quote 2) don't use a space as a delimiter.where? you mean space in line 4 in my previous post? i removed it ! Quote 3) move your closing parenthesis after your IF statements.which one? the one in line 2 or 9 ? if i remove parenthesis in line 9 ) it wont be able to run it ! 4) You should put quotes around your variable names when dealing with file names and directory paths. i hope you mean names in line 2 . right? i put quotes around them "myflash.rar" "source.fla" "newfile.swf" "movie.flv" "*.reg" my final batch is below and it still is not working . i don't know which part is missing ! Quote @echo off & setLocal EnableDelayedExpansion1) In regards to using DIR /B /S. Do you understand why you need to use both of those switches. Just type DIR /S at a cmd prompt, then type DIR /B /S and you should see why. 2) NO! You are using a Space as a delimiter in your FOR LOOP! Either close up the space or get rid of the delims option all together. 3) Of course the last one. You need to end the code block in the correct spot. I didn't say REMOVE it. I said move it after your IF statements. 4) No! Those file names don't have any spaces in them. If they did you would need quotes. I specifically said VARIABLES! What do you think is going to happen to your IF EXIST test if their is a space in the directory path.Quote 1) In regards to using DIR /B /S. Do you understand why you need to use both of those switches. Just type DIR /S at a cmd prompt, then type DIR /B /S and you should see why. i just wanted my bat to SEARCH and look into sub-directories too ! Quote 3) Of course the last one. You need to end the code block in the correct spot. I didn't say REMOVE it. I said move it after your IF statements. brilliant my friend you are truly a master it worked like a charm Quote 4) No! Those file names don't have any spaces in them. If they did you would need quotes. I specifically said VARIABLES! What do you think is going to happen to your IF EXIST test if their is a space in the directory path.i think error was not because of those file names i didn't change them and it solved just that bad parenthesis ) and something else= i replaced line 3 with 4 and it solved !! my final working script is below thanks dear master Squashman Quote @echo off & setLocal EnableDelayedExpansionWell I hope your paths don't have spaces in them because it won't work if it does. |
|