Can this be done and if so HOW ? Please have a look

I am new to PHP and have not yet learned all the syntax and commends but was wondering if an easy script can be made to copy files of the same name from one directory over to another directory thru a PHP script

in other words if I have 2 folders

1 named Folder1
the other named Folder2

and I wanted to copy files that have the same name from folder1 to folder 2 and have it replave the files currently in folder2 with the ones it copies from folder1 could this be done

EX

Folder1 has files names

help.txt
card.txt
user.txt

and folder 2 has the same files but older non updated versions ... what script could I use to copy the ones in Folder1 and replace the existing ones in folder2

Any help would be most appreeciated

I am trying to learn from all this and use this for a project at the same time ...

Thank you so much anyone that spends a few minutes of thier time to help with this

[QUOTE=Midnite002;1111924]OK for the LAST TIME - I am not a student ... I am not here for homework ... and I am not asking for HAND OUTS ... I am simply a new person to PHP programming and I am asking for a little help with creating a script that … Read More

EV - this is what he said:
[QUOTE]I was kinda hoping someone would be kind enough to make a working script that I could implement and learn from at the same time ... [B]I am crunched for time and really dont have the time right now[/B] to fully learn all … Read More

I was kinda hoping someone would be kind enough to make a working script that I could implement and learn from at the same time ... I am crunched for time and really dont have the time right now to fully learn all I would need to in order to get this done...

I was kinda hoping someone would be kind enough to make a working script that I could implement and learn from at the same time ... I am crunched for time and really dont have the time right now to fully learn all I would need to in order to get this done...

Again if anyone can help I would be most greatful

Thanks
Midnite

Slavery has been abolished in most civilised countries and online forums. You don't have the time, but you want members to give up their precious time to do your work for you. Perhaps you want to resubmit your request? There again, you may find some sap or young buck on this forum who'll do it out of sheer ego.

Votes + Comments

Midnite002:I think being rude to someone new asking for help is very unfair to someone who is NEW

Can someone please help with this ... I thought thats what we are all here for to help one another ... not to be nasty and make rude comments to someone that is not as knowledgeable as others in certain programming languages ... I asked for help ... didint ask to be ridiculed

Thanks for those that do help

those that pass judgement ... thats not cool ... I am an inexperienced PHP programmer asking for assistance

Did you look at scandir() in addition to copy() as previously mentioned? Ardav is merely pointing out that you seem to want people here to write scripts for you, but you haven't demonstrated any effort on your own at all. If you believe that his comments are unfair, show that you're trying to make some headway with this yourself when you ask for assistance.

I have tried this on my own and have had no luck with it ... that is why I am here asking for help ... if someone was kind enough to do so I would learn from what they did and figure out how to do future scripts on my own -

I am simply asking for help to do something I need to and will play with the script and learn from it on my own ... just lost as to where to start ...

Can someone please help with this ... I thought thats what we are all here for to help one another ... not to be nasty and make rude comments to someone that is not as knowledgeable as others in certain programming languages ... I asked for help ... didint ask to be ridiculed

Thanks for those that do help

those that pass judgement ... thats not cool ... I am an inexperienced PHP programmer asking for assistance

Thanks again
Midnite

Not trying being nasty - just giving you a heads up. Asking for help is as you say the whole point of this type of forum. However, it is generally accepted that you make some sort of effort yourself.

I apologise if my post was a bit strong. On reflection, I should not have been so sarcastic.

I am still prepared to help if you post some code of your own as a starting point for discussion. The whole point of posting your own code is that you learn more from your own successes and failures than from dissecting somebody else' script - which may itself be erroneous. It also offers members many access points for support and thereby generates a busy thread.

Can someone please help with this ... I thought thats what we are all here for to help one another ... not to be nasty and make rude comments to someone that is not as knowledgeable as others in certain programming languages ... I asked for help ... didint ask to be ridiculed

Thanks for those that do help

those that pass judgement ... thats not cool ... I am an inexperienced PHP programmer asking for assistance

Thanks again
Midnite

Experienced PHP programmer?
Here's what you say in your first post in this thread:
"I am new to PHP and have not yet learned all the syntax and commends but was wondering if an easy script can be made to copy files of the same name from one directory over to another directory thru a PHP script"

You have been given hints, but you still have no code to show.
That is why we suspect that the deadline you are up against is your homework is due, but you would rather play beer pong while some other shmuck does your work for you.

The very premise of what your are trying to do smacks of an academic exercise, not anything that one would normally use PHP for.
I would think a shell script would be a better choice.

I have tried that is the POINT I dont know where to start i am new to this so i dont understand the syntax ? i can do this in shell script yes but what I dont understand in PHP is how to setup a loop like say how do I create a counter that would do the following

I am trying to start at 12am then go to 1am 2am etc like the hours in a day till 11pm then switch to 12pm and then 1pm and then continue till 11pm ....

I have setup and gotten the copy part to work I just dont know how to set a variable to the names of the files that I want to copy ...

see this is my code but what I need is to set a changing variable that will do each hour instead of hard coding each one as in my example

The point is I am not exp in PHP and therefore I am trying to learn how to do so ... and asking for somone to write something for me to learn from ... I dont understand the constant need to be put down told I am not trying ETC ETC accused of doing so for some academic credits at some school ... thats all just nonsense .. all I did was state that I am not an EXP php programmer and asked if someone could make a script to do what I was asking and then I would take it apart disect it and learn from it .... its that simple really

ardav - Who is bitchin ? And I never asked for a meal ticket - where do you see me asking for that ? I asked for someone to create a script that does what I am trying to do so that I can test it and learn from it ... I never said HE MAKE HTIS FOR ME and THANKS ALOT ... OK second where did you get the idea that I needed the filesize of the txt files ? where did I ask about that ? I dont remember doing that and I see nowhere in my message that states that ...

What I said was I wanted to create a loop that would go thru the files in the folder and that they were labeled ...

12am, 1am, 2am, 3am ETC till 11am then 12pm,1pm,2pm till 11pm ...

That is all I asked about

JRM - Thank you for your assistance so far ... I see the difference in what you are doing as opposed to what I first created ... and I understand your reason behind copying first then testing ...

What I am trying to do is make the file titles in these variables change to each hour without having to write 24 files one for each hour

or something like that - the problem I am having is making the counter to change the filename starting with 12am ( which may need to be seperate ) and then 1am-11am and then another seperate one again for 12pm and then a counter for the hours 1pm to 11pm ...

I do not know how to create the changing variable ... that would become the file name

in effect I am trying to copy the files from one directory to another ... is there a way to just copy a whole DIR from one to another maybe that would make it easier for me to figure out

ardav - Who is bitchin ? And I never asked for a meal ticket - where do you see me asking for that ? I asked for someone to create a script that does what I am trying to do so that I can test it and learn from it ... I never said HE MAKE HTIS FOR ME and THANKS ALOT ... OK second where did you get the idea that I needed the filesize of the txt files ? where did I ask about that ? I dont remember doing that and I see nowhere in my message that states that ...

What I said was I wanted to create a loop that would go thru the files in the folder and that they were labeled ...

12am, 1am, 2am, 3am ETC till 11am then 12pm,1pm,2pm till 11pm ...

That is all I asked about

JRM - Thank you for your assistance so far ... I see the difference in what you are doing as opposed to what I first created ... and I understand your reason behind copying first then testing ...

What I am trying to do is make the file titles in these variables change to each hour without having to write 24 files one for each hour

or something like that - the problem I am having is making the counter to change the filename starting with 12am ( which may need to be seperate ) and then 1am-11am and then another seperate one again for 12pm and then a counter for the hours 1pm to 11pm ...

I do not know how to create the changing variable ... that would become the file name

in effect I am trying to copy the files from one directory to another ... is there a way to just copy a whole DIR from one to another maybe that would make it easier for me to figure out

Thanks
Midnite

Midnite,
Me thinks you protest too much! You really need to put forth more effort
Anyway, if you want the hours to correlate to the local time .
look here us3.php.net/manual/en/function.localtime.php
The PHP site is an excellent resource.
probably the localtime() function should be of interest. You can extract the hour of local time from the array. It is, however a 24 hour clock. If you want to do the Am pm thing, futher conversion will be necessary.

$filhnd = @opendir($dirname);
if (!$filhnd)
{
printf ("<b>Directory [%s] not opened </b><br />", $dirname);
}
else
{
while ($fil = readdir($filhnd))
{
## now $fil contains a filename from the directory.
## It could be anything, even a subdirectory name
## so you have some testing to do.
## Then if the filename is worth saving:
$filelist[] = trim($fil);
}
closedir($filhnd);
}

Ardav,
You've got a lot more patience than me. I'd have chucked this threat ages ago.

Midnite,
The posters on here have been trying to help you learn. And learning isn't easy it takes _your_ effort. Through out this post you've asked for a script so you can test it and examine it to see how it works. Write your own and you'll know how it works.
You might wish to change your login name too, I'll be very reluctant to answer your posts.

OK for the LAST TIME - I am not a student ... I am not here for homework ... and I am not asking for HAND OUTS ... I am simply a new person to PHP programming and I am asking for a little help with creating a script that will do what I am trying to do ... why all the attitude and negativity ... look if you dont want to help then just keep your feelings thoughts and opinions to yourself cause honestly I am not interested in someone that knows a programming code that I am not familiar with RUNNING off at the mouth cause they know more then I do ... SIMPLE you dont want to help then dont but passing judgement on somone or closing threads that they are opening to ask for help from those that are willing to do so is just totally ignorant and wrong ....

I am working on MY personal website and that is what I want this script for and to learn from ... its very simple and instead of running off with the drama why wouldnt you offer to help somone ...

I dont just cut and paste code I change it modify it and learn from it as I do ... so why the UNNEEDED DRAMA ...

OK for the LAST TIME - I am not a student ... I am not here for homework ... and I am not asking for HAND OUTS ... I am simply a new person to PHP programming and I am asking for a little help with creating a script that will do what I am trying to do ... why all the attitude and negativity ... look if you dont want to help then just keep your feelings thoughts and opinions to yourself cause honestly I am not interested in someone that knows a programming code that I am not familiar with RUNNING off at the mouth cause they know more then I do ... SIMPLE you dont want to help then dont but passing judgement on somone or closing threads that they are opening to ask for help from those that are willing to do so is just totally ignorant and wrong ....

I am working on MY personal website and that is what I want this script for and to learn from ... its very simple and instead of running off with the drama why wouldnt you offer to help somone ...

I dont just cut and paste code I change it modify it and learn from it as I do ... so why the UNNEEDED DRAMA ...

If you are not a young person, you certainly have a healthy sense of entitlement like many "20 somethings" do.
Why don't you study this stuff, write bad programs ,and hone your skills like the rest of did?
What makes YOU above all of that effort?
If you don't have an interest in writing programs, but want a personal website, hire someone who knows what they are doing to design it for you...or better yet ,have your parents pay for it like they always do.

JRM = first of all I am probably older then you are ... secondly I have no problem learning and writing bad code like all the rest but what I was asking for was a starting point so that I had an idea on what I was doing and a direction to head in

JRM its simple like I told all the others if you dont want to offer to help then dont no need to throw around your uncalled for comments or attitude ... its that simple ... its real easy to be aman with a big mouth behind a PC ... ISNT IT !!!

But how many of you are MEN ? not code kiddies ( I mean hell you whine like your 5 WAHHHHH you want help WAHHHHH you dont want to learn like the rest of us did WAHHHHH ) oh just stop already here is your pacifier baby ... now as I said if you have nothing but BS to throw around save your breathe cause I really dont care to hear what you or any of the other whiners have to say

I really dont care to hear what you or any of the other whiners have to say

Go to another forum. You've obviously ruffled the feathers of everybody here - some of whom would go the extra mile to ensure a solution for you (myself included). This isn't a dig, just a fact. OR do as AB suggests, get a new login and calm the hell down.

JRM its simple like I told all the others if you dont want to offer to help then dont no need to throw around your uncalled for comments or attitude ... its that simple ... its real easy to be aman with a big mouth behind a PC ... ISNT IT !!!

I guess that works pretty well for you too..eh?
Believe me, if I met you in person you would have heard the same.
I fear no man...especially one who thinks the world owes him something.
Now, a guy who takes charge of his destiny might be more of a challenge...but that ain't you.
Just stop all the nasty rhetoric already!
We told you what this board's culture is like, but you don't want to fit in.
Since nobody is going to write code for you, you might as well move on to "greener pastures" if you can find them.
Keep it up, and you will probably get banned anyway.

I was kinda hoping someone would be kind enough to make a working script that I could implement and learn from at the same time ... I am crunched for time and really dont have the time right now to fully learn all I would need to in order to get this done...

He doesn't have the time, but thinks that we do. He even gave me a neg rep for pointing out this erroneous thinking. Well, that's the end of any help I'm prepared to offer. Huh, I can imagine that he'll get himself a new login with the name Midnite003!:icon_lol: