 We're going to be looking at removing spaces from filenames. It's very poor practice to put spaces in filenames, especially if you're a programmer and you know this can be a headache, if you don't account for it, which you should always account for it, even though people shouldn't do it. But I've created a bunch of empty files here, and you can see they have spaces. In fact, it's kind of hard here to see where one file begins and where another ends. So let me go ahead and list these out long ways, and you can see that we have files with spaces in their names. So let's say you want to get rid of the spaces in these names. You can replace them with other characters or remove them completely. There's different ways to do this. Today we're going to use the rename command, which is a very useful command, but not available on all systems. So I'm going to show you this in this video, and in the next video I'm going to show you how to use sed, which is a little more common to loop through files and rename them. So what we're going to do is we're going to use sed to substitute, and if you've ever done, I'm sorry, renamed to substitute, if you ever used sed, you're probably familiar with commands like this, but we're going to say rename, and then inside single quotes we're going to say s forward slash forward slash forward slash g. And what we're doing here is we are saying to substitute whatever characters in between these two slashes, whatever is between these two slashes, and we're doing that globally. We're not stopping at the first instance. And then we're going to say to do this to all files, and also be very careful when renaming files that you don't overwrite files or, yeah, just make sure you know what you're doing. You don't want to mess up your files. So I'm bulk renaming here, but be cautious when doing that. So what am I going to do here? I'm going to say space. So we're going to say, okay, rename, and that means all files, take the file's name and substitute for all spaces. I'm going to say a underscore here. So I'm going to hit enter. And now if I list out my files, you can see the spaces have been replaced with underscores. Let's go ahead and then let's say we want to change it back. All we have to do is change it so it says replace all underscores with spaces. Enter and I can list that out. And you can see our spaces are now back. And I can go back up to our command here and instead of replacing it with an underscore I can say with a dash. And now we have dashes instead of spaces, both which are better than spaces in file names. Let's go ahead and move it back. So now I'm replacing all those dashes with spaces. And you can see we're back to our original file names. I am now going to delete the spaces, meaning the words are all going to be pushed together in the file names. I don't necessarily recommend this. It's not something you can undo. But I'm going to say substitute in the file name all spaces and I'm not going to put anything between these two forward slashes. Which means replace them with nothing. I hit enter and you can see our files now have names all pushed together. Probably in most cases not what you want to do. Not going to be easy or even possible to automate undoing that because there's no character there anymore to replace. It's all just one long string of letters. But I thought I'd show you that anyway. So I hope you found this tutorial useful. If you don't have a rename on your system, we're going to use a little bit of a loop in the next video and a few commands to rename them in a similar fashion. So I thank you for watching and as always, please think about supporting patreon.com.com. It should be a link in the description. Visit my website, filmsbychris.com. That's Chris at the K. There should be a link to that in the description as well. Also in the description a link to the full playlist. If you can't support financially, think about supporting by liking, sharing, subscribing and commenting below. Let me know what you think in the comments below. Thanks for watching and as always, I hope that you have a great day.