 So lots of times when you're writing shell scripts You just kind of can point a directory or a group of files and filter through and just process through them If you need to process files with your shell scripts thing is sometimes you want to select certain files and not the others Well today, we're going to be looking at selecting multiple files with your shell script and then processing through them now my favorite way of doing this is Right in the shell without any GUI interface Using fzf and most time this is a great option also to quickly search and filter through files You can multi-select but the thing is there are certain scenarios where you may want more than just a text interface Most time I recommend a text interface but the example I've come up with today is we're going to grab set of images and We're going to process through them and we're going to convert them from color to De-saturated or a black and white and move them to a new folder and we don't want to do a whole directory We want to select the ones we want and for that sometimes it's nice to have a GUI interface You can see the thumbnails you pick now. I have four or five scripts. I wrote we're going to go over today I'm going to show you them running quickly look at how they work But then in the future videos over the next coming weeks We're going to look at each script one by one look at the pros and cons and exactly how they work So let's jump in and have a look at this. Okay. Here. We are first off get lab dot-com Ford slash middle X 1000 there'll be links on my web page But there I have a project called bash multi file select and in there We'll have all the shell scripts that we're going to be looking at today that I've created and forget And getting to work is once you go into one of them You just have to change the variables for the input and output folders that you want to work with but that's where you can get all the scripts we're looking at today and Let's go ahead and jump right in here. I am in my shell I'm in that project clone from git lab and over here on the right is my file manager on the right side I have a split screen here and I have the folder that we're starting with which has color images and when we process the ones We select they're going to show up in this directory over here in a desaturated black and white so let's look at my first and In for most things. I think the best option, which is fcf fuzzy finder. So my script here files Files underscore fcf it will point to that directory list out all the files It's listing out the full path name you could and you know write more for the script to just show the file name But I wanted to keep the script as short as possible for this demonstration now if you're not familiar with fcf It's pretty simple if we want to multi-select. I can just select one I go up to the one I want I hit enter in a process It's now I have a black and white copy of that image if I wanted to select more though My script is set up so I can tab I can hit tab you can see the little arrows If I want to remove one I can remove it down at the bottom it tells me how many photos or files there are How may we're displaying and how may I have selected I could hit enter and it will start processing through those and I can open those up and Start just looking at all of them So there we go. So we're doing good so far one of the big benefits of fcf is That it's a fuzzy finder now very simple example here I only have so many files But you can have lots of files and you can simply search them But in this case, let's say I want to select the HDR files I can type in HD oops HDR and it shows them all and I'm sure there's a shortcut key to select all once you do that But it's also real quick just to hold down tab so they're all selected I'll hit enter and now it's converting all those to a gray scale over here Okay, now that we've looked at fcf. Let's look at another option. I'm going to delete out this all the files in this directory Going to now do my Zenit option Zenit is great if you want simple gooey dialogue boxes for the most part I'm gonna tell you avoid gooey's right because it's just easier to use the shell It's quick to use shell you can ssh in don't have to worry about forwarding and all that stuff It's just cleaner will work on more systems, but Maybe you want a gooey, right? So here it is it opens it up. I can select the ones I want I can control select I can shift select what I want And then when I hit okay it will process through them It doesn't have that nice fuzzy finding search features So if you had a lot of files all name different things it's a lot harder to find the ones you're looking for You can't just type and select them real quick But some people for some reason find this more comfortable than the same list in the shell Now the problem with both these options is you don't see the thumbnails of the images you're selecting I really don't know what images I'm selecting as I know them by name And I'm pretty sure if anyone knows if sanity has an option for thumbnails Please let me know I've looked through here and I quickly googled it and then come across anything, but Hit cancel here click okay, whatever Let's look at an option where we do have thumbnails a few options So let me clear this out the next one we have is going to be called Files thumbnails so files thumbnails. I'm gonna cat that out. Just so you know this must be installed. It's called SX IV it's in your repositories. I first learned about this program watching a video by Luke Smith and If I run my files that thumbnails what's gonna do is it's going to direct to the directory this directory over here with my original photos and That SX IV or VI whatever the program was. It's just an image viewer So it's going to open up Right like this I can make it full screen if I want but I can see the thumbnails and I can move around I can enter to go into one I can hit spacebar to go to the next I can enter go out of that But the thing is what it lets also let you do is I can press M And you can see when I press M It puts a little square in the bottom corner of the thumbnail I can also hit M on an image to remove it if I'm in the full screen mode and I hit M You can look down here It's kind of small but in the bottom right see my mouse cursor here little arrow There's an asterisk there that means this image is selected hit M again and unselect it and as I'm going through the photos So if I was hit space here this one space here You can see that one's already selected and again enter to get out of that now when I kill this program It's going to pass all the selected ones back to my script So I'll close out of this program and it starts processing all the ones that I checked. It's great. It's not spectacular because it works great if you're familiar with it But if you're not familiar with it who would think to press M to I'm assuming M stands for mark to mark an image That's kind of weird and then it doesn't have an okay select link because it's an image viewer But it will pipe them back out or dump them back out to your script when you exit So if you're writing a script for yourself or a worker who you can train It's a good option, but it's not a good option. Just send out to somebody who's like just the regular Joe out there So that that's the biggest drawback to that option in my opinion but it does work and Again, these are options that are simple options without having to design a full interface for your images Now let's look at drag-and-drop options So if you had a script or any program, you know, you can be like blah, blah, blah Whatever name of the program is and you can be like file File to or one file to and you can pass it multiple files Well, the thing is you can drag and drop and that's kind of what it does So if you were to select some images and drag and drop into the shell it just drops them in there You would think that these quotation marks these these single quotes these apostrophes would help divide it up But it doesn't actually really work very well that way But we are going to look at two options where you can drag and drop from pretty much any file manager into your script And I have two of them, but I'm actually gonna start with the first one. I called drop to So files drop to I'm gonna hit enter and he says no such so because I didn't pass anything This particular one before you run the script you select the images you want So I'll select this one and this one and this one and I'll drag them here and when I hit enter Am I did I move out of my directory? Oh I did drop to okay. Sorry file. You got actually typed in the proper name of the script Now I can drag and drop before I run my script drop them in as arguments Right, and then when I hit enter it's going to process through each one That's nice if the person knows dragon. I'm not and you can type them out too But it's easier to drag and drop and I'm dragging dropping the full directory now There is a another option Where we actually use the read command inside the script So if I go to my files drag drop the first one without the two at the end when I hit enter It actually says please drag and drop drag files drag and drag drag and drop. I'll fix that typo But now I can drag and drop files and when I hit enter it processes through And it's actually processing through the same ones because I selected the same ones But if I select another one, I can run this as well And The thing is after you drag it you have to click into the shell and then hit enter So it'd be nice if you can get to run without that I did see a script that does kind of do that that someone else wrote But it was very complicated. I wanted my script to be simple as far as looking at the code So you have to drag and drop click in the shell and then hit enter So a big drawback. That's one of the biggest drawbacks this the big one Some of the biggest drawbacks this is that you have to open up a file manager go to the directory You select the images start up the script then drag over there So a good option would probably be to in your script have it open up the directory in the default file browser That'd be probably the quickest option I didn't do that for Demonstration purposes and also you can have a combination of the two so my drag and drop and my drag and drop too You can have it where it checks if arguments were passed and if they were files and if they weren't And then ask people to drag and drop to it So that's another option and you can actually make combinations of all these if something was passed in the shell Not if you have zennedy available and there's a GUI available run it if not then use fcf But they all so far all of these four images have had not the best options The first two options are best for most files But if you're working something images or maybe even videos with thumbnails You want some sort of GUI interface where you can see a thumbnail and these are the options I've come up with the the scenarios. I've come up with without having to actually go into another programming language and write a whole GUI interface now if you have knowledge of a better option to very simply Create you know view thumbnails and pass them to your script Let me know if you're interested in more on how these work and we can look at some of the pros and cons more In the code writing wait for my future videos over the next couple of weeks I will go over each one of these scripts one at a time and and they're all pretty short. So like if I cat out some I am Files fuzzy finder one. Look the top is just you know my header here. The code is just this here. It's not very long Basically input folder. Oh, also I purposely put spaces in the file names and the folder here Because these scripts would actually be easier if you didn't have to worry about spaces and file names But since some people do put folders and files with spaces I wanted to take that into account. So I purposely made Folders with spaces in them, which I would normally try to avoid doing But that's it. It's getting a directory for input and output creating a directory and then Looping through the images pass them to fcf and then processing them It's breaking. Yeah, I'm going over the script. That's for future video. Thanks for watching my website films by Chris com That's Chris the K. There's a link in the description as always. I hope that you have a great day