Hi,
I need a batch file to delete all PDF files in a folder and it's subfolders. I will be giving the folder path and number of old days to delete as static values..
Please it's very urgent. Also I have a VBScript file which works fine for the same. -
-
Option Explicit
-
Dim FSO, WshShell, Then_Date, WSHShellENV, TempFolder, Recycled ' variables needed for main program(local scope)
-
On Error Resume Next
-
Set FSO = CreateObject("Scripting.FileSystemObject") ' a new object to gain access to a computer's file system
-
Set WshShell = WScript.CreateObject("WScript.Shell") ' an object in type specified
-
Set WSHShellENV = WSHShell.Environment("PROCESS")
-
-
Set drv = FSO.GetDrive("D")
-
DoDir FSO.GetFolder("D:\TUSA\TUSA\CallCentre\CustomerReports")
-
DoDir FSO.GetFolder("D:\TUSA\Tusa\CustomerPortal\CustomerReports")
-
-
Then_Date = DateAdd("d", -5, Date) ' Files older than 5 days
-
WScript.Echo "Cleaned Files on " & Now & ". " & " Erased Files older than " & Then_Date
-
-
Sub DoDir(Folder)
-
Dim i, File, SubFolder, fstr, pos, last_mod ' variables needed for function
-
Dim Now_Date, Then_Date ' variable used for today's date
-
Now_Date = Date ' loads today's date into variable Now_Date
-
Then_Date = DateAdd("d",-5, Now_Date) ' Files older than 5 days
-
-
-
Dim Findstr(0) ' an array named Findstr with array element one
-
Findstr(0) = ".PDF" ' loads into array element 0, the .txt file extension
-
For Each File In Folder.Files ' For each file in folder.files
-
FStr = UCase(File.Path)
-
-
-
'WScript.Echo(FStr)
-
Pos = 0
-
for i = 0 to 0
-
if ((instr(FStr, Findstr(i)) > 0) And (File.DateCreated < Then_Date)) then
-
-
' check whether there exists a string inside FStr
-
' which has an extension of any of the elements of FindStr
-
-
'WScript.Echo(FStr) ' echos file string
-
-
File.delete ' if there is, simply delete it
-
Exit For
-
End if
-
Next
-
Next
-
For Each SubFolder in Folder.SubFolders
-
DoDir SubFolder
-
Next
-
End Sub
-
-
Sub ClearFolder(Folder)
-
Dim File, SubFolder
-
For each file in Folder.Files
-
File.delete(True)
-
next
-
'For Each SubFolder in Folder.SubFolders
-
' SubFolder.Delete(True)
-
'Next
-
End Sub
-
-
Thanks
Manoj
0 1946 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Shyguy |
last post by:
I have a database that backs up critical tables to a database, named
Backup with the date, daily. I can't figure out how to delete these
databases programmatically, say when they are 5 days old or older. I
was able to figure out how to delete them if they are 5 days older
then current date but the weekends and holiday, etc. leave some
undeleted.
Any help will be greatly appreciated,
ShyGuy
|
by: Charles Neitzel |
last post by:
I'm trying to write a windows application in C# (Using Microsoft Visual C#
2005 Express) that is nothing more than a simple UI with buttons on it. The
buttons do various things like running programs and executing registry
entries. The majority of my buttons work however, I have come upon a problem.
I need a few of the buttons to run DOS batch files, the batch files in turn
run program installers (specifically windows update runtime .exe...
|
by: Charles |
last post by:
I'm trying to write a windows application in C# (Using Microsoft Visual
C#
2005 Express) that is nothing more than a simple UI with buttons on it.
The
buttons do various things like running programs and executing registry
entries. The majority of my buttons work however, I have come upon a
problem.
I need a few of the buttons to run DOS batch files, the batch files in
turn
run program installers (specifically windows update runtime .exe...
|
by: Sky Sigal |
last post by:
I have created an IHttpHandler that waits for uploads as attachments for a
webmail interface, and saves it to a directory that is defined in
config.xml.
My question is the following:
assuming that this is suppossed to end up as a component for others to use,
and therefore I do NOT have access to their global.cs::Session_End()
how do I cleanup files that were uploaded -- but obviously left stranded
when the users aborted/gave up writting...
|
by: Martin Ho |
last post by:
Can someone help me with this please? I wasn't very clear in my old
post.
I have a program to copy files from one location to another, now I
want to copy only those files which were created on certain date. How
do I compare the file (date created) to system date?
Something like this doesn't work:
if System.IO.File.GetCreationTime(path to my file) = date.Now then
copy ....
| |
by: |
last post by:
Hello,
I am attempting to convert multiple .wav files to the .flac format via a batch script. I know that this can be done with numerous software implementations automatically for me; however, i am interested to understand how to create a script to perform my purpose and since this function is useful, what the hey! I am rather new to batch files but would appreciate any help. TIA
My process thus far has been the following:
I edited the...
|
by: Beagle |
last post by:
I have a batch file that I am using to delete older files in a directory. It runs great from Windows 2000 computers. However, I now need it to run from Windows XP and it won't. Will one of you much more knowledgable individuals take a look at it and tell me why?
Thanx,
Beagle
Here it is:
:: --------DELOLD.BAT----------
@ECHO OFF
|
by: techusky |
last post by:
I made a script that successfully creates a .zip file of all the files
in a directory on my web server, but now what I haven't figured out
how to do is how to have it automatically deleted when the user
successfully downloads it, as otherwise my server would eventually get
clogged up with all these zip files.
Any help/suggestions?
Thanks
|
by: SPE - Stani's Python Editor |
last post by:
Phatch is a simple to use cross-platform GUI Photo Batch Processor
Phatch handles all popular image formats and can duplicate (sub)folder
hierarchies. It can batch resize, rotate, apply perspective, shadows,
rounded corners, ... and more in minutes instead of hours or days if
you do it manually. Phatch allows you to use EXIF and IPTC tags for
renaming and data stamping. Phatch also supports a console version to
batch photos on web...
|
by: =?Utf-8?B?UnVzdHlfUm9zZXI=?= |
last post by:
Hi everyone,
I'm having some issues figuring out how to complete certain tasks
with a batch file, whether it be not knowing the right syntax or if it can
even be accomplished with a batch file. Heres my problem.
I work in the IT department at a local bank and we are in the
process of deploying new PCs for some of the employees with older work
stations. I just finished staging about a dozen of them and in the next month
or so we will...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |