ajoo Posted March 3, 2020 Share Posted March 3, 2020 Hi all, I wish to copy files from source to destination but the source and destination information has to be read from a file. As an example, I wish to copy from 1. e:/dev/eb/fran/*.* to e:/prod/eb/fran/*.* 2. e:/dev/eb/inc/*.* to e:/prod/eb/inc/*.* and so on. More generally I would like a put the source and destination information in a file as below 1. e:/dev/eb/fran/A.html e:/prod/eb/new_fran/A.html 2. e:/dev/eb/inc/B.php to e:/prod/eb/new_inc/B.php and so on and then use it to copy the files. Thanks ! Quote Link to comment https://forums.phpfreaks.com/topic/310192-simple-file-copying/ Share on other sites More sharing options...
requinix Posted March 3, 2020 Share Posted March 3, 2020 Is this a one-time thing? I hope not. You're intending to write this file and then make changes over time? Add or remove things? How is this being used? Why is this being used? Quote Link to comment https://forums.phpfreaks.com/topic/310192-simple-file-copying/#findComment-1575102 Share on other sites More sharing options...
ajoo Posted March 4, 2020 Author Share Posted March 4, 2020 Hi requinix ! Hope you are doing good. hmm, you got most of it correct Well I have a a project in development whose copy i wish to create and remove all comments from it before uploading to the vps. The development site gets cluttered with so many additional files during development. The main files, added or deleted are only a few. So it becomes really cumbersome to separate the wheat from the chaff. I thought if I can have a list of files with path then i can simply maintain that list and use that to copy and paste from the dev to the other location. Thanks ! Quote Link to comment https://forums.phpfreaks.com/topic/310192-simple-file-copying/#findComment-1575110 Share on other sites More sharing options...
requinix Posted March 4, 2020 Share Posted March 4, 2020 Isn't that kinda just covering up the problem, though? If you have all these files you don't want, why do they exist at all? Consider using Git. For multiple reasons, but two relevant reasons are: 1. You can see exactly what changes have been made since the last time, so I'd think it would be easier to delete what you don't want to keep. 2. If these files are being created for some reason that makes sense, you could have Git ignore those files so they stay on your machine. Either way, you make the changes you want, commit and push, then go onto the live server and pull them down. It's a cheap and easy deployment strategy too - certainly better than copying files over FTP or something like that. Quote Link to comment https://forums.phpfreaks.com/topic/310192-simple-file-copying/#findComment-1575112 Share on other sites More sharing options...
ajoo Posted March 4, 2020 Author Share Posted March 4, 2020 Hi Requinix, To begin with, I am using the GIT. The new files are generated during testing and debugging. I am using the linux to remove the comments from the files. The comments, besides the normal comments, can be a number of echos, exits, etc. scattered throughout my files across the project that i keep commenting on and off as needed. i want to remove all those and get my final files that I would use to set up on the VPS. Yes Maybe I can setup a git for these cleaned files as well and use that to install the project on the vps. Hence I need to find a way to copy and paste files from a maintained file. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/310192-simple-file-copying/#findComment-1575113 Share on other sites More sharing options...
requinix Posted March 4, 2020 Share Posted March 4, 2020 Oh, the problem isn't files themselves but code inside files? You want the code to run locally but not on the live site? Quote Link to comment https://forums.phpfreaks.com/topic/310192-simple-file-copying/#findComment-1575114 Share on other sites More sharing options...
ajoo Posted March 4, 2020 Author Share Posted March 4, 2020 Yes, I need to remove the commented out code as well as the comments ( probably less than the commented code) from the files and then use those on the live server. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/310192-simple-file-copying/#findComment-1575116 Share on other sites More sharing options...
kicken Posted March 4, 2020 Share Posted March 4, 2020 Why bother removing all the commented stuff before deploying? If it's commented out then it wont run. If you want some extra code to run locally for debugging then rather than constantly comment/uncomment the code make it conditional on something. For example I setup an environment variable on my development systems called DEBUG_SERVER and can test for that in the code to enable extra stuff. Finally if you really need to be doing some sort of processing before deploying, you could look into something like gulp. Quote Link to comment https://forums.phpfreaks.com/topic/310192-simple-file-copying/#findComment-1575123 Share on other sites More sharing options...
ajoo Posted March 4, 2020 Author Share Posted March 4, 2020 Hi Kicken, Thanks for the response, I'll think about your suggestion and decide what to do. I'll look into gulp. I have no idea what it does. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/310192-simple-file-copying/#findComment-1575125 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.