SilverHaze420 Posted May 8, 2005 Share Posted May 8, 2005 Is there any way to find out how many files are in folders? What I want to do is search for all my music folders that have one file in them and combine all the folders. I can not figure out a way to find out what folders only have one song tho. Anybody have ideas? Link to comment Share on other sites More sharing options...
un4given1 Posted May 8, 2005 Share Posted May 8, 2005 This might work for you.... for /f "tokens=1 delims= " %i IN ('dir ^| find "File(s)"') DO Echo %i Link to comment Share on other sites More sharing options...
totoymola Posted May 8, 2005 Share Posted May 8, 2005 Wow! Nice code! Link to comment Share on other sites More sharing options...
un4given1 Posted May 8, 2005 Share Posted May 8, 2005 Thank you... Link to comment Share on other sites More sharing options...
SilverHaze420 Posted May 9, 2005 Author Share Posted May 9, 2005 Thanks! Now umm what do I do with that code? Link to comment Share on other sites More sharing options...
Yzöwl Posted May 10, 2005 Share Posted May 10, 2005 To use the line above, open a cmd prompt and navigate to the directory you are wishing to count files in, then enter it at the prompt!The following batch file will currently show 'on screen' all of your directories containing only one file.onefile.cmd@echo offfor /d /r "%~1" %%a in (*) do ( for /f "tokens=1" %%b in ('dir "%%a" /a-d 2^>nul ^| find "File(s)"') do if '%%b' equ '1' call :dostuff "%%~a")goto :eof:dostuffecho %1goto :eofTo use this one open a cmd prompt and navigate to the directory containing this batch file. At the prompt typeonefile "Drive:\Folder Path"where "Drive:\Folder Path" is the location of the directory you wish to 'count files' in. (you only need the quotes if there is a space in the folder path)If you can explain 'combine all folders' I may be able to help with the rest, otherwise if you wish to do it yourself, just replace the line echo %1, under the :dostuff label with your new commands. Just as a note, the qualifying directories within this section will remain named as %1 Link to comment Share on other sites More sharing options...
Yzöwl Posted May 11, 2005 Share Posted May 11, 2005 I have updated the code in my above reply to better reflect your requirementsAlso, just as a note, bear in mind that the directories may contain hidden thumbs.db or desktop.ini files which could bring unpredictable results.Run the batch as it is for now and check the results on screen for such anomalies first! Link to comment Share on other sites More sharing options...
SilverHaze420 Posted May 15, 2005 Author Share Posted May 15, 2005 Thanks. I think I had too many folders for that script to work. I get the error "the full path of is too long." I downloaded a program called treesize. That tells me how big the folders are so I guess that will do. Thanks for trying guys! I never even knew the command "for" was allowed thought it was some vb script or something lol. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now