Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old March 23rd, 2007, 03:42 PM
Sabadecade Sabadecade is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2007
Posts: 2 Sabadecade User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 43 sec
Reputation Power: 0
Automatic File update

I'm looking for something like JamesLe's VB script that Shadow wizard modified...

Quote:
Originally Posted by Shadow Wizard
here is the modified script:
VB Code:
Original - VB Code
  1. Option Explicit
  2. Dim fso
  3. Set fso = CreateObject("Scripting.FileSystemObject")
  4. Call DeleteFiles(fso.GetFolder("C:\Test"), 7, ".txt") '<----- Change this folder name to match with your case.
  5. Sub DeleteFiles(srcFolder, daysCount, strExtension)
  6.     Dim srcFile, filesCount
  7.     filesCount = 0
  8.     If srcFolder.Files.Count = 0 Then
  9.         Wscript.Echo "No File to Delete"
  10.         Exit Sub
  11.     End If
  12.     For Each srcFile in srcFolder.Files
  13.         If DateDiff("d", Now, srcFile.DateCreated) < ((-1)*daysCount) Then
  14.             If (strExtension="") Or (Right(UCase(srcFile.Name), Len(strExtension))=UCase(strExtension)) Then
  15.                 fso.DeleteFile srcFile, True
  16.                 filesCount = filesCount+1
  17.             End If
  18.         End If
  19.     Next
  20.     Wscript.Echo filesCount & " Files Deleted successfully"
  21. End Sub


I really like the idea and could find much use for such a script. As opposed to outright deleting the file, I would like to overwrite it with a copy of a more current file from another location (i.e. from a network drive).

Any VB experts willing to help me tweak it some more? Thanks in advance!

Reply With Quote
  #2  
Old March 26th, 2007, 10:42 AM
TheJim01 TheJim01 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 45 TheJim01 User rank is Corporal (100 - 500 Reputation Level)TheJim01 User rank is Corporal (100 - 500 Reputation Level)TheJim01 User rank is Corporal (100 - 500 Reputation Level)TheJim01 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 12 h 4 m 23 sec
Reputation Power: 5
Where it deletes the file, just use CopyFile instead and allow it to overwrite...
Code:
fso.CopyFile pathToYourMoreCurrentFile, srcFile, True

Reply With Quote
  #3  
Old March 26th, 2007, 02:38 PM
Sabadecade Sabadecade is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2007
Posts: 2 Sabadecade User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 43 sec
Reputation Power: 0
Perfect, thanks TheJim01!

I wish I knew how to do this stuff myself.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Automatic File update


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT