Solved

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

Posted on 2014-09-22
4
410 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 17

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 17

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
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 if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …

623 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