Solved

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

Posted on 2014-09-22
4
376 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

This article will help you understand what HashTables are and how to use them in PowerShell.
A procedure for exporting installed hotfix details of remote computers using powershell
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 while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

911 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now