1.

Solve : Batch to list files modified today in text file.?

Answer»

Can anyone tell me what the batch file command(s) are to write a list of all "*.doc" modified today to a text file. Any help would be greatly appreciated.Is this your homework?

You already asked this in another thread. Why have you abandoned that one to start this new thread? Didn't you like my answers?


The last question was to start a new batch file based on any doc file being modified today. I just want to list all files that are modified now. I FIGURED that the last post was a closed issue and that it might not get read. Your answer solved my first question. Like I said I am somewhat of a newbie.

I am actually trying to use pieces of information from other people's post to accomplish a task that a co-worker has to do manually right now. The task doesn't really involve doc files but I can modified the file type in the batch files to cover that. If you really want to KNOW everything I am trying to do with this I would be happy to post it, just did want to ask someone else to write the batch file for me without first trying myself.

Thanks,
Psycho DanOK. I'm glad you didn't just want somebody to write the batch file for you, because many people do seem to want exactly that, and it gets to be a pain in the *ss.

Everybody has their own way of doing these things but I personally would probably do it this way

1. Set up a loop to examine the output of 'dir /b *.doc'
2. In the loop, get each file's date and time string by using the %%~t variable modifier
3. Put this string in a variable.
4. Obtain the first 10 characters of this string, which will be dd/mm/yyyy or mm-dd-yyyy or whatever depending on your local date format. There are a number of ways of doing this.
5. Compare this with the variable %date% which will be today's date in the same format.
6. If they match, the file was modified (or created) today.

I can foresee complications/missed files if its running time spans midnight unless you get today's date right at the beginning.




here's a vbscript:
Code: [Select]Set objFSO=CreateObject("Scripting.FileSystemObject")
myDocFolder = "c:\temp"
Set objFolder = objFSO.GetFolder(myDocFolder)
N=Now
theDateNow = Year(N)*1e10 + Month(N)*1e8 + Day(N)*1e6
For Each myDocs In objFolder.Files
If objFSO.GetExtensionName(myDocs) = "doc" Then
theDocDate = myDocs.DateLastModified
N=theDocDate
theFileDate = Year(N)*1e10 + Month(N)*1e8 + Day(N)*1e6
If theFileDate = theDateNow Then
WScript.Echo "Same day file: " & myDocs
End If
End If
Next
usage:
Code: [Select]c:\> cscript myscript.vbs > newlist
ghostdog, he wrote he didn't want anyone to write him a batch file without trying it himself, so what do you do? Write him a vbs script! Is there any situation in life that does not prompt you to churn out a vbs script and post it?

Quote from: contrex on October 01, 2007, 11:44:47 PM

ghostdog, he wrote he didn't want anyone to write him a batch file without trying it himself, so what do you do? Write him a vbs script!
any problem with that? i did not write a batch for him, did i? you have already provided him guidance, so i guess he will try to do the batch himself. there are many ways to solve a problem, i am just showing him some other ways. Somebody may COME in and do a Perl script for him, who knows?... if he wants to stick with batch, that's entirely up to him.

Quote
Is there any situation in life that does not prompt you to churn out a vbs script and post it?
1) when i am unhappy
2) when i am busy
3) when i don't feel like it.

this is a public forum, what i post are valid suggestions/solutions that may/or may not solve the problem, as long as i don't violate posting rules (or be rude to people and get banned). You can't stop me from posting just because you feel you don't like it. Just like i can't stop you from asking people "is this homework" everytime someone does that, right?.Sorry, Ghostdog, for being testy with you. I had just got up! Actually that is a very interesting VBscript you contributed. Quote from: contrex on October 02, 2007, 02:00:27 AM
Sorry, Ghostdog, for being testy with you. I had just got up! Actually that is a very interesting VBscript you contributed.
hey..no problem the script follows the method you posted. I was able to write a batch file to do it, but I am always interested in learning new way to do things. Thanks to both of you for your help. I thought about trying vbscript but I would be totally lost on that, so maybe I will try it after I get my batch files working without needing daily input from me (which I am almost there thanks to contrex's help).

Thanks again,
Psycho DanI think you will be using delayed expansion inside the loop
Contrex I am a newbie to this myself but I have noticed that you tend to have an "I really cant be arsed with helping but !! I will, under duress attitude" and then you can can be quite helpful are you manic depressive.

Cos it really doesn't help when u dont know what your doing then some one makes you feel moronic for asking. So lighten up we aint all "au fait" with this and we dont want to be hand held just pointed in the right direction Quote from: w33man on October 05, 2007, 08:26:55 AM
Contrex I am a newbie to this myself but I have noticed that you tend to have an "I really cant be arsed with helping but !! I will, under duress attitude" and then you can can be quite helpful are you manic depressive.

Cos it really doesn't help when u dont know what your doing then some one makes you feel moronic for asking. So lighten up we aint all "au fait" with this and we dont want to be hand held just pointed in the right direction

w33man, thank you for your interest in my mental health. Comment how you like about the ACCURACY or otherwise of my answers. It's a free forum. Catch me out in an error - great. The truth is served. Answer a question better, more fully, more helpfully than me - fantastic! Way to GO! But - consider the ratio of 7:1882. That is how much weight I attach to your opinion about my attitude and personal style. Well, rather less actually. Sorry but there it is.

(Paraphrase: go pound sand.)






Discussion

No Comment Found