Computing.Net > Forums > Programming > Batch code to search for new files

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch code to search for new files

Reply to Message Icon

Name: aegis
Date: May 6, 2008 at 12:25:20 Pacific
OS: XP Home SP2
CPU/Ram: AMD 64/2gb
Product: Generic
Comment:

I need a batch file to search a bunch of sub folders. The following is an example:
main\sub1\new
main\sub2\new
main\sub3\new
etc
I need to search all the 'new' folders for files. If any are found then display the 'sub?' name followed by the files in its new folder. I would really appreciate it if someone would help me out.



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: May 6, 2008 at 23:07:36 Pacific
Reply:

@echo off

for /f "tokens=* delims= " %%a in ('dir/s/b/ad \ ^|find /i "new"') do (
echo %%a
dir /b/a-d "%%a"
)


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 2
Name: vishuonly4u
Date: May 6, 2008 at 23:16:29 Pacific
Reply:

aegis...

try using this in loop

set directorytoscan=main\

for /f "tokens=*" %%i in ('dir/a-d/b/s %directorytoscan%')

and u can use windows schedule job to run this job in regular interval of time.


0

Response Number 3
Name: Razor2.3
Date: May 7, 2008 at 01:59:52 Pacific
Reply:

@for /r main /d %%a in (new) do @dir /b /s "%%~Fa"


0

Response Number 4
Name: aegis
Date: May 7, 2008 at 11:04:21 Pacific
Reply:

They work fine and it's amazing what you folks can do with just a few lines of code. Mechanix2go's method worked the best for me, but there was one 'minor' problem. The screen overflows with lines showing the empty folder names and 'File not found' mesages for the folders with no files in them.
I don't want to appear ungrateful, but it sure would be nice if only the folders 'with files' would show up and those 'file not found' lines wouldn't.

If not, thanks very much guys (or gals as the case might be)!!!!


0

Response Number 5
Name: Razor2.3
Date: May 7, 2008 at 15:42:37 Pacific
Reply:

Attach the following to the end of the implementation of your choice:

2>NUL


0

Related Posts

See More



Response Number 6
Name: aegis
Date: May 7, 2008 at 16:12:33 Pacific
Reply:

Thanks a lot Razor2.3! That got rid of the 'File not founds'.


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch code to search for new files

Batch to scan for new files www.computing.net/answers/programming/batch-to-scan-for-new-files/14489.html

Searching for Hidden Files. www.computing.net/answers/programming/searching-for-hidden-files/17203.html

Need program to scan for a file ..... www.computing.net/answers/programming/need-program-to-scan-for-a-file-/19026.html