Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Copying Files

00:00 Next, I want you to copy this hello_terminal file into a subdirectory named hello. Okay. A few operations there, I guess.

00:14 So there’s a few things we need to do. We need a new folder called hello. That was the name of the folder, right? Yeah. Okay, so now if I list (ls) in here, we’ll see that we’ve got the folder and the file.

00:30 The folder has this blue highlighted thing to show you that it’s a folder. Okay, so the mkdir command stands for make directory? Correct, yes, I used mkdir to to create the folder, so mkdir with the folder name afterwards, and that made it.

00:49 Okay, so now to copy the hello_terminal file into the hello\ subdirectory, what’s the command there? Well, it’s cp, also for copy.

00:59 I believe the full command is copy-item, copy-item. But you can just use cp. And then you just take the file path or the path that you want to copy. I’m just going to use tab auto-complete here as well.

01:13 And then you pass in the path that you want it to be moved to. So in this case, I can just put the folder name, and it will copy that into hello\. So I can press Enter here. Okay—And so— Go ahead. Again, the terminal doesn’t output anything, which it sometimes does.

01:34 Like with some commands you get some feedback, but with others not. Yes. I’m not sure what the rhyme or reason is there. I don’t know why cp wouldn’t have an output, whereas make would.

01:47 I’m not sure what the logic is there, but I’m sure they had a good reason for it. Okay. So maybe a rule of thumb is the other way around. If the terminal doesn’t complain, it probably did what you wanted it to do, or at least, it did something and hopefully what you wanted it to do. Right, that’s a good point.

02:05 If you don’t get any output, it can either mean nothing happened or it went through the command without an error. If it does run into an error, it will usually complain.

02:16 Like if I just said something like realpython , which is not a command on my computer, it will give me an error. It will say that it’s not recognized as the name of a command.

emru67 on Jan. 19, 2024

Hi, this is what I get when I try to run the python script:

> PS D:\programming\python\tests\pb_terminal> python .\
SyntaxError: Non-UTF-8 code starting with '\xff' in file D:\programming\python\tests\pb_terminal\ on line 1, but no encoding declared; see for details

The Terminal writes the file in UTF-16 LE BOM, even after changing CHCP to 65001.

This is the only way I found to write an utf8 file (although utf8 BOM) and it works:

PS D:\programming\python\tests\pb_terminal> echo 'print("Hi utf-8 Terminal!")' | out-file -encoding utf8

PS D:\programming\python\tests\pb_terminal> python

Hi utf-8 Terminal!

How did you manage to avoid all that? I’m on Windows 10, just downloaded the windows terminal as per your instructions yesterday (01-18-24).


Become a Member to join the conversation.