 Okay, I'm recording this video for a friend but I figure I share it with everybody because why not and I'm gonna do this I'm gonna create a virtual server for this so I'm working from a very you know basic system rather than doing on a system I already have set up and I'm using vulture services I'm not making money from that. That's just who I use for my servers The reason I do is because it only cost me two dollars and fifty cents a month Although that sale seems to be over and it's five dollars a month I'm gonna spin up a server here real quick and go to so vulture.com and creating account Click deploy a new server. I'm gonna choose that location. I'm in Florida. So I'm just gonna click a server closest to me I'm gonna choose a Debian server. I'll do Debian 864 bit again the two dollars and fifty cents Sale is over. So it's gonna cost me point zero zero seven cents an hour So let's try to do this video in less than an hour. How about that? So I'm gonna choose that don't any other special features. I'll give it a name and I'll just call it photo Sort of whatever doesn't really matter for this and click deploy. That's all you have to do It's gonna take probably less than two minutes and I'm gonna have a Debian server that I can log into So what are we gonna be doing with this server? We're going to be using two scripts that I've created in the past This one here, which is a PHP slash HTML script Which allows you to upload files and I just want to be aware. I'm showing you how these script works I'm gonna set the server then remove it. So so but I'm not gonna be working on any login information This script right here allows whatever user has access to it to upload whatever files they want There's no restrictions on file type file size or anything of that nature And I'm not going over any, you know creating user accounts and logging in That's all separate information But that's what we're gonna go over. So this file is not very big and that will create our Uploadable script and then once the files are uploaded My buddy wants to be able to sort the images based on address. So this is a script. I wrote here It's a little bash script That takes an image grabs the GPS information from it if it's available ask Google for the street address then we'll create a folder called photos and inside that full folder it will create a Folder based on the street name and then another folder inside that that's based on the numerics of the address and then put The image in there. So we'll sort all images By the by the address. Let's go back to our little server here and our Debian server is up and running so now I can click on this and Right here. This is where you get your password. You can copy it and Without looking at it and then once you log in you want to change it, but I'm gonna delete the server anyway So I'm just gonna copy that you can click on this little console here and get a login shell But I can't I don't think I can resize that I much rather just use a real shell so Again coming here. I'm actually gonna need the IP address because I don't have a domain pointing at this address yet But I'm gonna say SSH and by default I'm gonna log in as root now again if you're actually setting up a virtual server You're gonna want to go in there Create a new user disable root login best practice, but again, I'm not going over the security of it I'm just going setting up these scripts. So I'm gonna hit enter I'm gonna type in yes, cuz my first time logging in and again. I'm going to copy and Paste my password that should work. There we go. I'm logged into a brand new Debian install on this server So at this point, let's go ahead and do some install stuff So I'm root so I don't have to type sudo for anything in here, but I'm gonna say apt and I'm gonna say update Just do a quick update which should just take a second. I'm gonna say apt Install I'm gonna say PHP 5 which will also install Apache 2 for me I'm gonna hit enter on that and That should just take a second and when that is done. I can now grab that IP address Put it in my web browser and we have a web server up and running perfect So that web server is going to be under your var www. Sorry forward slash HTML and so that's the HTML file. We're looking at I'm just going to remove that and What I'm going to do is I'm going to make a directory called upload it and I'm going to change its permissions to 777 Because you need to have the permissions proper for being able to upload to that folder and it needs seems to be need full permission But clear the screen here real quick, okay Now it's time to download our first script and there'll be links in the description of this video It's all these scripts. So here's my PHP code. I'm just gonna copy the URL and inside my web server here I'm gonna say W get That link I'm gonna say output index dot h or actually PHP And now if we refresh our browser that's pointing at the server, we have this upload screen and at this point I can say choose a file and I can choose this little script allows you to upload multiple files and again There's seems to be no restrictions as far as the script goes I have found that the virtual the virtual server that I'm running It seems to be limitations if I try to upload a bunch of files all at once. It doesn't work the large numbers So you'll want to Check what your server is allowed to do and if you have to upload a bunch of files You may want to rewrite the script to kind of do one at a time So that's just a server thing doesn't do a script I'm gonna choose five of those files. I'm gonna say upload. She'll only take a second We got those files there and I'm gonna upload the second half and say upload So that is how you can upload the files and you can do that from a mobile device anything anything with a modern web browser Now those all those fault all those images should have gone into our Uploaded folder that we created and here they are you can see them and I can click on them and view them my kids at the mall my son at Wendy's My wife and I out for a walk So they're all there now. Let's work on the script that is going to sort all these images for us So that would be this script here again. There'll be a link in the description There are a few things we need to install. I need to install the Exif tools which allows a tool to grab information from an image such as the GPS coordinates So let's go ahead and I'm gonna say apt install Exif tools Now that's installed now I'm gonna pull this file from Pastebin Which unfortunately is in a DOS format and since it's a script we need to convert it to a Unix format So I'm gonna say apt install DOS to Unix Okay, now I could put that script inside this folder, but I'm actually going to put it inside our CD USR local bin So I'm gonna go into that folder. I'm gonna say W get and I'm gonna give it the URL to this File and say output and I can call it whatever I want I'm gonna call it sort.sh which probably isn't the best because there already is a sort command So I don't want to just call it sort, but I'll call it sort sh.sh So that's downloaded. So let's now run our DOS to Unix on that script. Boom. It's now The characters in it are fixed and we can make that xcubal change mod plus x that file At this point, I believe I have everything installed that I need. I'm gonna go back to my web browser my web directory and Actually go into my uploads folder And here are all my images. So now I can say sort.sh and give it one of these files So I'll give it this one here. That should be the first one. I hit enter Let's see. Oh It also needs the BC command which is installed on most distributions of Linux by default But apparently not on this this install of Debian. So I'm gonna say apt install BC BC is a Calculator for the command line and I've got to convert the the GPS Coordinates into the proper format for Google. So that's what my script uses that for so let's see. Let's list photos Okay, so it moved that one file into the photo. So let's go ahead and move that back My mistake for not having BC installed So let's try running that script again So sort.sh or whatever you name the script and the file There we go. So it should have created it. This is the full address right here Inside our photo photos folder There should be now this folder and inside that folder is the numeric and then it should have put that file in there So if we list photos Tammy and me trail and that address and we can see that files in there so Now we want to run it on all of those images So all you have to do is say for and give it a variable and I say I in all dot JPEG and I would do the dot JPEG Instead of just an asterisk for a few reasons one It's gonna you don't want to try to run this on other files that aren't images because it might cause the script to crash Also, we also have the folder in their photos and that can throw it for loop So we're just gonna say look at all that JPEG But remember this case sensitive. So if your extension is a capital JPEG, you're gonna want to adjust that then we're gonna say do and Again sort.sh and then dollar sign I for our variable here So that will be our file name as it loops through each file And then we'll say done and We'll go ahead and hit enter and it should run through each one of those now remember I am using Google's API for their Google Maps and they do limit you to 25,000 Requests a day for free. So if you need more than that, you're going to want to purchase more Requests but going back to our uploads folder here in our web browser and you can install better-looking Index pages than this. This is just the default Apache. I'm gonna refresh this now You can see we have our photos folder We can go in there and now we have all our addresses and we can go into one of those and then we can click on the address There there's the image and we can look on it from the browser there and That's pretty much it. That's what we want to go over doing and if there was more than one here like this one Had I took two pictures at the same location My son by a fire truck my son inside the fire truck so those images were taking at the same place So they were put into the same folder That's pretty much it I mean, I think I kind of talked a little fast going through this. I didn't want more you but it's a video You can slow it down or pause it if you need it But that is setting up a virtual server Debian server and getting both these scripts running on there and installing all the requirements It wasn't that hard and now like I said with this since it's a web interface here Anyone you give and again, you're gonna have to set up Permissions if you're gonna open this up to the world or even on a local network You're best to do some sort of login Of some sort so you don't have just anybody uploading anything But besides that saying this up anyone with a phone or a tablet or a laptop or a desktop anything with a modern browser Can now upload files to this and as far as running the script You can have this script for sorting them run every time someone uploads it You can add it to the PHP file here You can just do a system call on it if you want or just set a cron job to run every minute That checks that folder for new photos I mean unless you need it instantaneously, but if you're just trying to sort files You know for projects later on down the line saying a cron job that runs every minute or so or how we're often that runs this That should be good enough Which I do have videos on cron jobs. So just search my videos if you go to filmsbychris.com and It should bring you to the video search and if we just type in cron you can see I've got Two you want to probably get this cron tab basic tutorial. We'll go over how cron works and actually there is a Website, I don't know if I mentioned this previous video. I think it's called cron tab Generator Go ahead and click on there and you can this will create a cron tab file for you So if you want something to run every minute every odd minute You just check what you want and then it will name of the script you want to run and it will generate at the Command for you to put into your cron tab, which is very nice instead of trying to Look up because every time I use cron tab. I have to look up, you know, how everything is organized anyway I do thank you for watching. Please visit my website again. It's filmsbychris.com There should be a link in description as well as a link to the scripts That were used in this video go ahead and check them out and as always I hope that you have a great day. Oh and also visit my patreon page patreon.com for Mellix 1000 there you can help support my website again. I hope that you have a great day