Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-09-22
4
Medium Priority
?
439 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 1500 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

Protect Your Retail Business and Reputation

Wi-Fi access doesn't just impact your business & customer experience, it can also affect your security.  Join us for an informative webinar to learn more about the top threats and trends impacting retail today, and the key solutions to protecting retail networks and reputations.

Question has a verified solution.

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

A brief introduction to what I consider to be the best editor for PowerShell.
A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
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 …
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…

664 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