PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > ms..win.server.scripting > RE: Script to echo files based on specific dates
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
RE: Script to echo files based on specific dates

Réponse
 
LinkBack Outils de la discussion
Vieux 03/10/2007, 17h39   #1 (permalink)
tonyr
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: Script to echo files based on specific dates

also if your new to scripting I'd make the switch to powershell, you
shouldn't have all the mental barriers us vbs guys have!
my .00000000001 cents worth

the equivelant I think would be

ls d:\somedir -rec | foreach {$_.creationtime -lt "01/02/2007"}

if its a remote device then

ls \\servername\d$\somedir -rec | foreach {$_.creationtime -lt "01/02/2007"}



"Walid" wrote:

> Hi,
> I am pretty new to scripting. I found this script from "scripting guy" and
> I want to know how I can echo or even delete files within a specific folder
> (for example D:\folder1\subfolder2\test) for files older than Jan 2nd 2007.
> I thought it would work if I change the line " AND Drive =
> 'D:\folder1\subfolder2\test'"). But this doesn't work. I would appreciate
> any !
>
> Thanks,
>
> WG
>
> strDate = "20070102000000.000000+000"
>
> strComputer = "."
> Set objWMIService = GetObject _
> ("winmgmts:\\" & strComputer & "\root\cimv2")
> Set colFiles = objWMIService.ExecQuery _
> ("Select * From CIM_DataFile Where CreationDate < '" & strDate & "'" & _
> " AND Drive = 'D:'")
> For Each objFile in colFiles
> Wscript.Echo objFile.Name
> Next
>
>

  Réponse avec citation
Vieux 03/10/2007, 17h53   #2 (permalink)
Walid
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: Script to echo files based on specific dates

Thanks for the tip. Is powershell different than VBScripting? I am running
WinXP Pro on my workstation so I believe I have to install it on my machine,
correct? Also, does the remote server that I query by the poweshell command
need to have it installed? As you can see I need some direction :-) Any
regarding this would be much appreciated.

"ls" would echo. What would be the delete command in powershell?

W

"tonyr" wrote:

> also if your new to scripting I'd make the switch to powershell, you
> shouldn't have all the mental barriers us vbs guys have!
> my .00000000001 cents worth
>
> the equivelant I think would be
>
> ls d:\somedir -rec | foreach {$_.creationtime -lt "01/02/2007"}
>
> if its a remote device then
>
> ls \\servername\d$\somedir -rec | foreach {$_.creationtime -lt "01/02/2007"}
>
>
>
> "Walid" wrote:
>
> > Hi,
> > I am pretty new to scripting. I found this script from "scripting guy" and
> > I want to know how I can echo or even delete files within a specific folder
> > (for example D:\folder1\subfolder2\test) for files older than Jan 2nd 2007.
> > I thought it would work if I change the line " AND Drive =
> > 'D:\folder1\subfolder2\test'"). But this doesn't work. I would appreciate
> > any !
> >
> > Thanks,
> >
> > WG
> >
> > strDate = "20070102000000.000000+000"
> >
> > strComputer = "."
> > Set objWMIService = GetObject _
> > ("winmgmts:\\" & strComputer & "\root\cimv2")
> > Set colFiles = objWMIService.ExecQuery _
> > ("Select * From CIM_DataFile Where CreationDate < '" & strDate & "'" & _
> > " AND Drive = 'D:'")
> > For Each objFile in colFiles
> > Wscript.Echo objFile.Name
> > Next
> >
> >

  Réponse avec citation
Vieux 03/10/2007, 17h59   #3 (permalink)
tonyr
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: Script to echo files based on specific dates

yes you need to install it and no the remote server\workstation does not need
it installed!

as a starter I'd go here

http://www.microsoft.com/technet/scr.../hubs/msh.mspx



"Walid" wrote:

> Thanks for the tip. Is powershell different than VBScripting? I am running
> WinXP Pro on my workstation so I believe I have to install it on my machine,
> correct? Also, does the remote server that I query by the poweshell command
> need to have it installed? As you can see I need some direction :-) Any
> regarding this would be much appreciated.
>
> "ls" would echo. What would be the delete command in powershell?
>
> W
>
> "tonyr" wrote:
>
> > also if your new to scripting I'd make the switch to powershell, you
> > shouldn't have all the mental barriers us vbs guys have!
> > my .00000000001 cents worth
> >
> > the equivelant I think would be
> >
> > ls d:\somedir -rec | foreach {$_.creationtime -lt "01/02/2007"}
> >
> > if its a remote device then
> >
> > ls \\servername\d$\somedir -rec | foreach {$_.creationtime -lt "01/02/2007"}
> >
> >
> >
> > "Walid" wrote:
> >
> > > Hi,
> > > I am pretty new to scripting. I found this script from "scripting guy" and
> > > I want to know how I can echo or even delete files within a specific folder
> > > (for example D:\folder1\subfolder2\test) for files older than Jan 2nd 2007.
> > > I thought it would work if I change the line " AND Drive =
> > > 'D:\folder1\subfolder2\test'"). But this doesn't work. I would appreciate
> > > any !
> > >
> > > Thanks,
> > >
> > > WG
> > >
> > > strDate = "20070102000000.000000+000"
> > >
> > > strComputer = "."
> > > Set objWMIService = GetObject _
> > > ("winmgmts:\\" & strComputer & "\root\cimv2")
> > > Set colFiles = objWMIService.ExecQuery _
> > > ("Select * From CIM_DataFile Where CreationDate < '" & strDate & "'" & _
> > > " AND Drive = 'D:'")
> > > For Each objFile in colFiles
> > > Wscript.Echo objFile.Name
> > > Next
> > >
> > >

  Réponse avec citation
Vieux 03/10/2007, 18h41   #4 (permalink)
Walid
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: Script to echo files based on specific dates

Thank-you all! This has been very ful!

"tonyr" wrote:

> yes you need to install it and no the remote server\workstation does not need
> it installed!
>
> as a starter I'd go here
>
> http://www.microsoft.com/technet/scr.../hubs/msh.mspx
>
>
>
> "Walid" wrote:
>
> > Thanks for the tip. Is powershell different than VBScripting? I am running
> > WinXP Pro on my workstation so I believe I have to install it on my machine,
> > correct? Also, does the remote server that I query by the poweshell command
> > need to have it installed? As you can see I need some direction :-) Any
> > regarding this would be much appreciated.
> >
> > "ls" would echo. What would be the delete command in powershell?
> >
> > W
> >
> > "tonyr" wrote:
> >
> > > also if your new to scripting I'd make the switch to powershell, you
> > > shouldn't have all the mental barriers us vbs guys have!
> > > my .00000000001 cents worth
> > >
> > > the equivelant I think would be
> > >
> > > ls d:\somedir -rec | foreach {$_.creationtime -lt "01/02/2007"}
> > >
> > > if its a remote device then
> > >
> > > ls \\servername\d$\somedir -rec | foreach {$_.creationtime -lt "01/02/2007"}
> > >
> > >
> > >
> > > "Walid" wrote:
> > >
> > > > Hi,
> > > > I am pretty new to scripting. I found this script from "scripting guy" and
> > > > I want to know how I can echo or even delete files within a specific folder
> > > > (for example D:\folder1\subfolder2\test) for files older than Jan 2nd 2007.
> > > > I thought it would work if I change the line " AND Drive =
> > > > 'D:\folder1\subfolder2\test'"). But this doesn't work. I would appreciate
> > > > any !
> > > >
> > > > Thanks,
> > > >
> > > > WG
> > > >
> > > > strDate = "20070102000000.000000+000"
> > > >
> > > > strComputer = "."
> > > > Set objWMIService = GetObject _
> > > > ("winmgmts:\\" & strComputer & "\root\cimv2")
> > > > Set colFiles = objWMIService.ExecQuery _
> > > > ("Select * From CIM_DataFile Where CreationDate < '" & strDate & "'" & _
> > > > " AND Drive = 'D:'")
> > > > For Each objFile in colFiles
> > > > Wscript.Echo objFile.Name
> > > > Next
> > > >
> > > >

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 03h48.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,11804 seconds with 12 queries