Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
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 …
Loops Section Overview

886 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