Solved

Python Script for check file name, type and date in windows folder

Posted on 2014-09-22
4
391 Views
Last Modified: 2014-11-20
Hello Expert,

I have a situation where we getting files every morning 9:00AM on our Windows Server directory, We looking to move these files from folder A to Folder B but before that we want to run few checks i.e. file name, file type, date, and if file not available by 9:05AM. If all checks clear we want to have a confirmation email or if no files there or bad name we also want to have an email alert.  
e.g.  
d:\reports\au_19092014_salesreports.csv (folder A)
d:\reports_Analytics\au_19092014_salesreports.csv (folder B)

We going to use Python for this(Or any better advise). I'm from Database background and never had experience with Python, So Would I as expert to help me get this done? Your support will be highly regards.

Regards,
Eddie
0
Comment
Question by:adnankh
  • 2
  • 2
4 Comments
 
LVL 16

Accepted Solution

by:
gelonida earned 500 total points
ID: 40338547
Hi adnankh,

this question is some kind of 'multi-question'
Are you just interested in a finished working script or are you interested in answers to the implicitely included questions?


1.) How do I check that filenames comply to a certain rule
(examples of wht you mean with rulesmight be useful and lead to differente answers ( glob / regexp / . . . )

2.) how do I check a file type?
(Do you want to check only the file suffix or really inspect the contents of the file to detect its type
os.path.splitext might be sufficient if you don't want to inspect the contents


3.) How to get the modification time of a file
os.path.mtime might be what you're looking for

4.) How to send emails with python



5.) How to copy files
shutils.copy might be the answer
0
 

Author Comment

by:adnankh
ID: 40340666
Hi Expert,

Are you just interested in a finished working script or are you interested in answers to the implicitely included questions?
I'm interested in working script. we need to do it asap, and unfortunately I've no experience in Python.. so would be great if I get some sort of sample python script. I'll play around and change it with client requirement.

Thanks in Advance
0
 

Author Comment

by:adnankh
ID: 40340673
For more clarification,
File name = au_sysdate-1_salesreport.csv
Arrival of files in folder A= 09:05AM everyday
0
 
LVL 16

Expert Comment

by:gelonida
ID: 40342889
Well then I let others handle this question.

I'm under a quite high work load at the moment and can only help to deblock certain small / perhaps tricky issues but at the moment I don't have time to do the complete code ASAP as you would need.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Utilizing an array to gracefully append to a list of EmailAddresses
"Migrate" an SMTP relay receive connector to a new server using info from an old server.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question