Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

Subject: Batch code to search for new files

Original Message
Name: aegis
Date: May 6, 2008 at 12:25:20 Pacific
Subject: Batch code to search for new files
OS: XP Home SP2
CPU/Ram: AMD 64/2gb
Model/Manufacturer: 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.

Report Offensive Message For Removal

Response Number 1
Name: Mechanix2Go
Date: May 6, 2008 at 23:07:36 Pacific
Subject: Batch code to search for new files
Reply: (edit)
@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


Report Offensive Follow Up For Removal

Response Number 2
Name: vishuonly4u
Date: May 6, 2008 at 23:16:29 Pacific
Subject: Batch code to search for new files
Reply: (edit)
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.


Report Offensive Follow Up For Removal

Response Number 3
Name: Razor2.3
Date: May 7, 2008 at 01:59:52 Pacific
Subject: Batch code to search for new files
Reply: (edit)
@for /r main /d %%a in (new) do @dir /b /s "%%~Fa"


Report Offensive Follow Up For Removal

Response Number 4
Name: aegis
Date: May 7, 2008 at 11:04:21 Pacific
Subject: Batch code to search for new files
Reply: (edit)
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)!!!!


Report Offensive Follow Up For Removal

Response Number 5
Name: Razor2.3
Date: May 7, 2008 at 15:42:37 Pacific
Subject: Batch code to search for new files
Reply: (edit)
Attach the following to the end of the implementation of your choice:
2>NUL


Report Offensive Follow Up For Removal

Response Number 6
Name: aegis
Date: May 7, 2008 at 16:12:33 Pacific
Subject: Batch code to search for new files
Reply: (edit)
Thanks a lot Razor2.3! That got rid of the 'File not founds'.

Report Offensive Follow Up For Removal



Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Batch code to search for new files

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software



Version Tracker Pro
Keep your software current and secure, effortlessly

Click Here for a Free Scan

Driver Agent
Automatically find the latest drivers for your computer.
Click Here for a Free Scan



The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC