Script to output result into text file on files in a directory

Hi,

I need a script, it could be powershell or a batch script to look into a directory that contains sub folders with files. I need it to export any .doc or .docx that was created on or after 25/10/2013 to a text file with the full location path or each file.

Many thanks

Luke
luketrAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

oBdACommented:
Powershell (could easily be turned into a one-liner):
$Directory = "C:\Temp"
$Include = "*.doc", "*.docx"
$FilterDate = Get-Date "25/10/2013"
$ResultFile = "C:\Temp\Results.txt"
Get-Childitem $Directory -Recurse -Include $Include | Where {$_.LastWriteTime -ge $FilterDate} | Select-Object -ExpandProperty FullName | Out-File $ResultFile

Open in new window

Edit: Forgot the output to a file.
0
oBdACommented:
For the fun of it, here's a version that uses robocopy.exe (it doesn't actually copy anything, so the target folder doesn't matter) and can handle file paths over 250 characters; works both in cmd and PS. Make sure you provide the date in question as YYYYMMDD:
robocopy.exe "C:\Temp" "C:\DUMMY" *.doc *.docx /maxage:20131025 /e /l /np /fp /ndl /nc /ns /njh /njs >C:\Temp\test.txt

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bill PrewCommented:
I know the question is closed, glad you got help, and I know you asked for a script, but I did want to mention a small free utility I have used for things like this that can save scripting.  It's called Swiss File Knife (SFK) and can make things like this pretty easy once you get the hang of it.  For example, here's a one line command that does what you needed:

sfk list c:\temp *.doc *.docx -since 20131025>c:\temp\list.txt

Open in new window

You can find the utility here:

http://stahlworks.com/dev/swiss-file-knife.html

~bp
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.