Computing.Net > Forums > Programming > Help on Batch File

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.

Help on Batch File

Reply to Message Icon

Name: aarya
Date: November 5, 2008 at 06:58:10 Pacific
OS: XP
CPU/Ram: -
Product: -
Comment:

Hi,

I need a batch application that would check a folder, find the files that has been modified after the last batch run and display the modified file names in a text file. Please somebody hellp me on this.



Sponsored Link
Ads by Google

Response Number 1
Name: Holla
Date: November 5, 2008 at 09:45:36 Pacific
Reply:

You may use xcopy /m
That is, your displaymodified.bat would look something like:


md c:\tempdir
xcopy /m C:\sourceDir C:\tempdir > c:\Dirlist.txt
del /q c:\tempdir

After copying, it resets archive attributes.
So when invoked second time, only the files with archive attribute set is copied.
c:\Dirlist.txt will contain the list of files copied.

--
Holla.


0

Response Number 2
Name: klint
Date: November 5, 2008 at 10:47:15 Pacific
Reply:

I like Holla's suggestion. I can offer an optimization. There's no need to do the copying, but just use dir /aa to list all files with the archive attribute set, and attrib -a to turn off the archive attribute. Then there's no need to create & delete a temporary folder either.


0

Response Number 3
Name: Mechanix2Go
Date: November 5, 2008 at 11:16:05 Pacific
Reply:

@echo off > modfile
setLocal EnableDelayedExpansion

for /f "tokens=2 delims= " %%a in ('attrib *.* ^| findstr /b "A"') do (
echo %%a >> modfile
)

attrib -a -s -h -r *.* > nul


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

M2


0

Response Number 4
Name: aarya
Date: November 5, 2008 at 20:30:05 Pacific
Reply:

Hi all,


Thanks for your your help.

Now i have a different problem.

When i build the files there are few file that will be built everytime. so how do i identified onlythe changed ones. Is there a way??


0

Response Number 5
Name: Holla
Date: November 5, 2008 at 21:51:06 Pacific
Reply:

klint,

I was thinking hard with xcopy /m, /l, etc.
Forgot about dir /a* .
This often happens with me, forget some obvious solutions and use a long solution where a diminutive :-) one would do.
Is it only me?
Is it more in batch programming?

Aarya,

Before the build, run

attrib -a *.*

and after the build list the dir with
dir /aa

this would give you the list of files that were newly created.

--
Holla.


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon

Batch File To Remove Cert... Is this a harmfull batch ...



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: Help on Batch File

Need help on Batch file for Shutdow www.computing.net/answers/programming/need-help-on-batch-file-for-shutdow/16424.html

Need help on batch file www.computing.net/answers/programming/need-help-on-batch-file/18119.html

Recommendations for a Book on Batch Files www.computing.net/answers/programming/recommendations-for-a-book-on-batch-files/19543.html