Computing.Net > Forums > Programming > search file/filetype from last mod?

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.

search file/filetype from last mod?

Reply to Message Icon

Name: sufian
Date: December 1, 2007 at 05:44:48 Pacific
OS: Vista
CPU/Ram: 1.8Ghz/2GB
Product: HP TC4400
Comment:

Hello everyone,

I need to come up with a batch script that can search the c: directory for file(s) that were modified today or within a week.

Do I have to search the file in c: using date so I could come up with list of files?

Kindly help

Sufian



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: December 2, 2007 at 05:13:08 Pacific
Reply:

This may need tweaking to accomodate the date style on your box.

Processing files a week old will take more doing.

===============================
:: process only today's files

@echo off > %TEMP%\#
setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in ('dir /s/b %TEMP%\#') do (
set mydate=%%~Ta
)

for /f "tokens=1 delims= " %%a in (' echo !mydate!' ) do (
set today=%%a
)

for /f "tokens=* delims= " %%a in ('dir/b/a-d') do (
set TD=%%~Ta
for /f "tokens=1 delims= " %%a in ('echo !TD!') do (
set filedate=%%a
)
if !filedate! equ !today! echo process %%a
)



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

M2



0

Response Number 2
Name: sufian
Date: December 4, 2007 at 08:32:13 Pacific
Reply:

Hi M2,thank you for the suggestion.

I try the script but it doesnt seem to work on my system. I am not that familiar with FOr command and I am having trouble understanding them.

For the 2nd part of the scipt, does it meant to convert the delimeter of the %Temp% to set mydate. I need something that can list the files from a specific date. Can you suggest to me any alternatives?

for /f "tokens=* delims= " %%a in ('dir /s/b %TEMP%\#') do (
set mydate=%%~Ta
)


0

Response Number 3
Name: Mechanix2Go
Date: December 5, 2007 at 00:45:55 Pacific
Reply:

Do this and post result.

======================
@echo off > %TEMP%\#
setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in ('dir /s/b %TEMP%\#') do (
set mydate=%%~Ta
echo !mydate!
)


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

M2



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







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: search file/filetype from last mod?

search-stop-search from last succes www.computing.net/answers/programming/searchstopsearch-from-last-succes/16552.html

move file by date last modified in a batch www.computing.net/answers/programming/move-file-by-date-last-modified-in-a-batch/20173.html

batch file name from selected file www.computing.net/answers/programming/batch-file-name-from-selected-file/15658.html