x

Output file attributes

Hi,

I am working on a script to get the FilePath, Filename and the created date displayed for any file which is in a Folder whose name is MRV. Let me explain in detail :

I have a Directory which has hundreds of folders and they have subfolders. One subfolder is named MRV in each folder. Now, I need to recursively go into each folder, look for MRV folder and DIR the filenames along with its Create date. I can have the output stored in a text file or in a SQL table. I tried to use the DOS command :

FOR /D %%a IN (C:\Test*) DO Dir /T:C /b /s %%a\MRV*.txt>>C:\List.txt

This gives me the complete paths for e.g as below:

C:\Test\ABC\MRV\63399862\mrv-abc-oth.txt

What I am looking for is something like :

C:\Test\ABC\MRV\63399862\mrv-abc-oth.txt 16/02/2010 14:32 PM

Can you suggest any way how the same can be done using SQL ?

more ▼

asked Feb 16 '10 at 03:08 AM in Default

Sagar Bhargava gravatar image

Sagar Bhargava
358 23 25 27

(comments are locked)
10|1200 characters needed characters left

2 answers: sort voted first

It may be possible with SQL but not recommended as there are far better ways to do it. If you dont get DOS to complete the task then LogParser or PowerShell will be a safe bet, after that a vbscript solution. All of these are better at accessing the file system than SQL.

more ▼

answered Feb 16 '10 at 05:55 AM

Fatherjack gravatar image

Fatherjack ♦♦
41.3k 73 77 107

Thanks. I got the DOS to generate the filepath and used OLE automation to get the file attributes and save it in a table.
Feb 17 '10 at 05:03 AM Sagar Bhargava
(comments are locked)
10|1200 characters needed characters left

You're using the /b switch which is suppressing output of the creation date.

more ▼

answered Feb 16 '10 at 04:25 AM

David Wimbush gravatar image

David Wimbush
4.7k 28 29 31

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x673
x66

asked: Feb 16 '10 at 03:08 AM

Seen: 783 times

Last Updated: Feb 16 '10 at 03:08 AM