|
Next: Fax archive folder
|
| Author |
Message |
External

Since: Jan 12, 2008 Posts: 15
|
(Msg. 1) Posted: Mon Aug 17, 2009 1:23 pm
Post subject: vbscript DateLastModified Archived from groups: microsoft>public>windowsxp>general (more info?)
|
|
|
The following script is a small piece of a larger script. I am trying to
move all text files that begin with "BA" and are older than today to a
different folder. The script does not give me any erros. The issue is that
is still moves all the files that begin with "BA" regardless of the date
modified.
3 files named:
BA20090815.txt
BA20090816.txt
BA20090817.txt
Only files BA20090815.txt and BA20090816.txt should be moved but all 3 files
are being moved.
If I put in the code wsh.echo objFile.DateLastModified the correct 2 files
appear. Here is the code:
Set fso = CreateObject("Scripting.FileSystemObject")
Set objfolder = fso.getfolder("c:\document\BLMed")
For Each objFile in objFolder.Files
If Left(objFile.Name, 2) = "BA" Then
If DateDiff("d", objFile.DateLastModified, Now) > 1 Then
fso.MoveFile "c:\document\BLMed\BA*.txt", "c:\document\BLMed\Logs\"
'wsh.echo objFile.DateLastModified
End If
End If
Next
I do not want to use a bat or cmd file or robocopy because this is a small
piece of a bigger script. The rest of the script works except this one piece.
Thanks! |
|
| Back to top |
|
 |  |
External

Since: Aug 17, 2009 Posts: 1
|
(Msg. 2) Posted: Mon Aug 17, 2009 5:25 pm
Post subject: Re: vbscript DateLastModified [Login to view extended thread Info.] Archived from groups: microsoft>public>windowsxp>general, others (more info?)
|
|
|
You need to post your message here:
<news://microsoft.public.scripting.vbscript>
or here:
<http://www.microsoft.com/communities/newsgroups/list/en-us/default.aspx?dg=microsoft.public.scripting.vbscript&cat=en_us_43e927c2-5a74-4f6a-bcdf-da786f7f48cc&lang=en&cr=us>
Hope this helps.
"Anonymous" <Anonymous.DeleteThis@discussions.microsoft.com> wrote in message
news:9161A3AF-6ED5-4B50-BD44-E298FBFAF9C4@microsoft.com...
> The following script is a small piece of a larger script. I am trying to
> move all text files that begin with "BA" and are older than today to a
> different folder. The script does not give me any erros. The issue is
> that
> is still moves all the files that begin with "BA" regardless of the date
> modified.
>
> 3 files named:
>
> BA20090815.txt
> BA20090816.txt
> BA20090817.txt
>
> Only files BA20090815.txt and BA20090816.txt should be moved but all 3
> files
> are being moved.
>
> If I put in the code wsh.echo objFile.DateLastModified the correct 2 files
> appear. Here is the code:
>
> Set fso = CreateObject("Scripting.FileSystemObject")
> Set objfolder = fso.getfolder("c:\document\BLMed")
> For Each objFile in objFolder.Files
> If Left(objFile.Name, 2) = "BA" Then
> If DateDiff("d", objFile.DateLastModified, Now) > 1 Then
> fso.MoveFile "c:\document\BLMed\BA*.txt", "c:\document\BLMed\Logs\"
> 'wsh.echo objFile.DateLastModified
> End If
> End If
> Next
>
> I do not want to use a bat or cmd file or robocopy because this is a small
> piece of a bigger script. The rest of the script works except this one
> piece.
>
> Thanks! |
|
| Back to top |
|
 |  |
External

Since: Jan 12, 2008 Posts: 15
|
(Msg. 3) Posted: Mon Aug 17, 2009 5:25 pm
Post subject: Re: vbscript DateLastModified [Login to view extended thread Info.] Archived from groups: microsoft>public>scripting>vbscript, others (more info?)
|
|
|
Thanks for the link. I looked for a scripting forum but didn't see this one
so didn't know it existed. Thanks again.
"NEW ANON" wrote:
> You need to post your message here:
>
> <news://microsoft.public.scripting.vbscript>
>
> or here:
>
> <http://www.microsoft.com/communities/newsgroups/list/en-us/default.aspx?dg=microsoft.public.scripting.vbscript&cat=en_us_43e927c2-5a74-4f6a-bcdf-da786f7f48cc&lang=en&cr=us>
>
> Hope this helps.
>
> "Anonymous" <Anonymous.RemoveThis@discussions.microsoft.com> wrote in message
> news:9161A3AF-6ED5-4B50-BD44-E298FBFAF9C4@microsoft.com...
> > The following script is a small piece of a larger script. I am trying to
> > move all text files that begin with "BA" and are older than today to a
> > different folder. The script does not give me any erros. The issue is
> > that
> > is still moves all the files that begin with "BA" regardless of the date
> > modified.
> >
> > 3 files named:
> >
> > BA20090815.txt
> > BA20090816.txt
> > BA20090817.txt
> >
> > Only files BA20090815.txt and BA20090816.txt should be moved but all 3
> > files
> > are being moved.
> >
> > If I put in the code wsh.echo objFile.DateLastModified the correct 2 files
> > appear. Here is the code:
> >
> > Set fso = CreateObject("Scripting.FileSystemObject")
> > Set objfolder = fso.getfolder("c:\document\BLMed")
> > For Each objFile in objFolder.Files
> > If Left(objFile.Name, 2) = "BA" Then
> > If DateDiff("d", objFile.DateLastModified, Now) > 1 Then
> > fso.MoveFile "c:\document\BLMed\BA*.txt", "c:\document\BLMed\Logs\"
> > 'wsh.echo objFile.DateLastModified
> > End If
> > End If
> > Next
> >
> > I do not want to use a bat or cmd file or robocopy because this is a small
> > piece of a bigger script. The rest of the script works except this one
> > piece.
> >
> > Thanks!
> |
|
| Back to top |
|
 |  |
External

Since: Jul 15, 2009 Posts: 43
|
(Msg. 4) Posted: Mon Aug 17, 2009 6:25 pm
Post subject: Re: vbscript DateLastModified [Login to view extended thread Info.] Archived from groups: microsoft>public>windowsxp>general, others (more info?)
|
|
|
"NEW ANON" <NEW.ANON.DeleteThis@MICROSOFT.COM> wrote in message
news:7F589C89-6AA9-4117-BDBE-E23E7A07A0A4@microsoft.com...
> You need to post your message here:
>
> <news://microsoft.public.scripting.vbscript>
>
> or here:
>
> <http://www.microsoft.com/communities/newsgroups/list/en-us/default.aspx?dg=microsoft.public.scripting.vbscript&cat=en_us_43e927c2-5a74-4f6a-bcdf-da786f7f48cc&lang=en&cr=us>
>
> Hope this helps.
>
> "Anonymous" <Anonymous.DeleteThis@discussions.microsoft.com> wrote in message
> news:9161A3AF-6ED5-4B50-BD44-E298FBFAF9C4@microsoft.com...
>> The following script is a small piece of a larger script. I am trying
>> to
>> move all text files that begin with "BA" and are older than today to a
>> different folder. The script does not give me any erros. The issue is
>> that
>> is still moves all the files that begin with "BA" regardless of the date
>> modified.
>>
>> 3 files named:
>>
>> BA20090815.txt
>> BA20090816.txt
>> BA20090817.txt
>>
>> Only files BA20090815.txt and BA20090816.txt should be moved but all 3
>> files
>> are being moved.
>>
>> If I put in the code wsh.echo objFile.DateLastModified the correct 2
>> files
>> appear. Here is the code:
>>
>> Set fso = CreateObject("Scripting.FileSystemObject")
>> Set objfolder = fso.getfolder("c:\document\BLMed")
>> For Each objFile in objFolder.Files
>> If Left(objFile.Name, 2) = "BA" Then
>> If DateDiff("d", objFile.DateLastModified, Now) > 1 Then
>> fso.MoveFile "c:\document\BLMed\BA*.txt", "c:\document\BLMed\Logs\"
>> 'wsh.echo objFile.DateLastModified
>> End If
>> End If
>> Next
>>
>> I do not want to use a bat or cmd file or robocopy because this is a
>> small
>> piece of a bigger script. The rest of the script works except this one
>> piece.
>>
>> Thanks!
How nice of Anon to do the crossposting for you! Instead of writing
fso.MoveFile "c:\document\BLMed\BA*.txt" . . .
you must write
fso.MoveFile objFile.path . . .
If you don't then you will move all files, thanks to the wildcard you left
in your code. |
|
| Back to top |
|
 |  |
External

Since: Jan 12, 2008 Posts: 15
|
(Msg. 5) Posted: Mon Aug 17, 2009 6:25 pm
Post subject: Re: vbscript DateLastModified [Login to view extended thread Info.] Archived from groups: microsoft>public>scripting>vbscript, others (more info?)
|
|
|
That did the trick. Thanks!
"Pegasus [MVP]" wrote:
>
> "NEW ANON" <NEW.ANON.DeleteThis@MICROSOFT.COM> wrote in message
> news:7F589C89-6AA9-4117-BDBE-E23E7A07A0A4@microsoft.com...
> > You need to post your message here:
> >
> > <news://microsoft.public.scripting.vbscript>
> >
> > or here:
> >
> > <http://www.microsoft.com/communities/newsgroups/list/en-us/default.aspx?dg=microsoft.public.scripting.vbscript&cat=en_us_43e927c2-5a74-4f6a-bcdf-da786f7f48cc&lang=en&cr=us>
> >
> > Hope this helps.
> >
> > "Anonymous" <Anonymous.DeleteThis@discussions.microsoft.com> wrote in message
> > news:9161A3AF-6ED5-4B50-BD44-E298FBFAF9C4@microsoft.com...
> >> The following script is a small piece of a larger script. I am trying
> >> to
> >> move all text files that begin with "BA" and are older than today to a
> >> different folder. The script does not give me any erros. The issue is
> >> that
> >> is still moves all the files that begin with "BA" regardless of the date
> >> modified.
> >>
> >> 3 files named:
> >>
> >> BA20090815.txt
> >> BA20090816.txt
> >> BA20090817.txt
> >>
> >> Only files BA20090815.txt and BA20090816.txt should be moved but all 3
> >> files
> >> are being moved.
> >>
> >> If I put in the code wsh.echo objFile.DateLastModified the correct 2
> >> files
> >> appear. Here is the code:
> >>
> >> Set fso = CreateObject("Scripting.FileSystemObject")
> >> Set objfolder = fso.getfolder("c:\document\BLMed")
> >> For Each objFile in objFolder.Files
> >> If Left(objFile.Name, 2) = "BA" Then
> >> If DateDiff("d", objFile.DateLastModified, Now) > 1 Then
> >> fso.MoveFile "c:\document\BLMed\BA*.txt", "c:\document\BLMed\Logs\"
> >> 'wsh.echo objFile.DateLastModified
> >> End If
> >> End If
> >> Next
> >>
> >> I do not want to use a bat or cmd file or robocopy because this is a
> >> small
> >> piece of a bigger script. The rest of the script works except this one
> >> piece.
> >>
> >> Thanks!
>
> How nice of Anon to do the crossposting for you! Instead of writing
> fso.MoveFile "c:\document\BLMed\BA*.txt" . . .
>
> you must write
>
> fso.MoveFile objFile.path . . .
>
> If you don't then you will move all files, thanks to the wildcard you left
> in your code.
>
>
> |
|
| Back to top |
|
 |  |
External

Since: Dec 04, 2008 Posts: 12
|
(Msg. 6) Posted: Tue Aug 18, 2009 1:31 am
Post subject: Re: vbscript DateLastModified [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
That is because he is GREAT.  )
--
All the Best,
Kelly (MS-MVP/DTS&XP)
Taskbar Repair Tool Plus!
http://www.kellys-korner-xp.com/taskbarplus!.htm
"Anonymous" <Anonymous DeleteThis @discussions.microsoft.com> wrote in message
news:C48C1C65-844C-47A8-A74D-E5690C82395B@microsoft.com...
> That did the trick. Thanks!
>
> "Pegasus [MVP]" wrote:
>
>>
>> "NEW ANON" <NEW.ANON DeleteThis @MICROSOFT.COM> wrote in message
>> news:7F589C89-6AA9-4117-BDBE-E23E7A07A0A4@microsoft.com...
>> > You need to post your message here:
>> >
>> > <news://microsoft.public.scripting.vbscript>
>> >
>> > or here:
>> >
>> > <http://www.microsoft.com/communities/newsgroups/list/en-us/default.aspx?dg=microsoft.public.scripting.vbscript&cat=en_us_43e927c2-5a74-4f6a-bcdf-da786f7f48cc&lang=en&cr=us>
>> >
>> > Hope this helps.
>> >
>> > "Anonymous" <Anonymous DeleteThis @discussions.microsoft.com> wrote in message
>> > news:9161A3AF-6ED5-4B50-BD44-E298FBFAF9C4@microsoft.com...
>> >> The following script is a small piece of a larger script. I am
>> >> trying
>> >> to
>> >> move all text files that begin with "BA" and are older than today to a
>> >> different folder. The script does not give me any erros. The issue
>> >> is
>> >> that
>> >> is still moves all the files that begin with "BA" regardless of the
>> >> date
>> >> modified.
>> >>
>> >> 3 files named:
>> >>
>> >> BA20090815.txt
>> >> BA20090816.txt
>> >> BA20090817.txt
>> >>
>> >> Only files BA20090815.txt and BA20090816.txt should be moved but all 3
>> >> files
>> >> are being moved.
>> >>
>> >> If I put in the code wsh.echo objFile.DateLastModified the correct 2
>> >> files
>> >> appear. Here is the code:
>> >>
>> >> Set fso = CreateObject("Scripting.FileSystemObject")
>> >> Set objfolder = fso.getfolder("c:\document\BLMed")
>> >> For Each objFile in objFolder.Files
>> >> If Left(objFile.Name, 2) = "BA" Then
>> >> If DateDiff("d", objFile.DateLastModified, Now) > 1 Then
>> >> fso.MoveFile "c:\document\BLMed\BA*.txt", "c:\document\BLMed\Logs\"
>> >> 'wsh.echo objFile.DateLastModified
>> >> End If
>> >> End If
>> >> Next
>> >>
>> >> I do not want to use a bat or cmd file or robocopy because this is a
>> >> small
>> >> piece of a bigger script. The rest of the script works except this
>> >> one
>> >> piece.
>> >>
>> >> Thanks!
>>
>> How nice of Anon to do the crossposting for you! Instead of writing
>> fso.MoveFile "c:\document\BLMed\BA*.txt" . . .
>>
>> you must write
>>
>> fso.MoveFile objFile.path . . .
>>
>> If you don't then you will move all files, thanks to the wildcard you
>> left
>> in your code.
>>
>>
>> |
|
| Back to top |
|
 |  |
| Related Topics: | Share : how to rip DVD and convert Video to iPod - Share : how to rip DVD and convert Video to iPod The article includes two parts. Part 1: Rip DVD movie to iPod (Windows) Part 2: Convert AVI, WMV, MPEG, RM, RMVB, ASF, MOV, DivX, XviD, MPG to iPod MP4 or H264 format (Windows) [1]How to rip DVD to iPod..
Auto Update - I am working on WinXP Pro (SP2). I have disabled Automatic Updates from Control Panel since I prefer doing it manually. Because I have disabled Automatic Updates, an icon (looks like a shield with a X in between & red in color) always appears next to...
my computer turns itself off (sony cpu running windows xp .. - this behavior has just begun, my computer will turn off, randomly. and to restart, i need to unplug the computer from the wall then push the on button. at about this same time, i noticed that my power mangement settings aren't working and also my..
Patch Package - Somehow my windows xp office 2003 is messed up. We bought our computer last year and did the update online and I don't have any idea about finding out what the product key is & what I need to do to fix it. So we bought Microsoft Works Suite 2006...
svchost.exe 100 % - Hi everybody. I got a problem... since 2-3 weeks when the update are done, the computer froze. It looks like it still downloading / installing the update but its not doing anything. When I go look in the process tab, svchost.exe is at 100 % I don't know.... |
|
You can post new topics in this forum You can reply to topics in this forum You can edit your posts in this forum You can delete your posts in this forum You can vote in polls in this forum
|
|
|
|