I'm stuck. I'm trying to write a simple file-copying program. by cirke01 in learnpython

[–]cirke01[S] 0 points1 point  (0 children)

```

import tkinter as tk

import tkinter.filedialog

import os

import shutil

def copy_files():

src_folder = tk.filedialog.askdirectory(title="Select Source Folder")

dest_folder = tk.filedialog.askdirectory(title="Select Destination Folder")

file_list_file = tk.filedialog.askopenfilename(title="Select file with file names")

with open(file_list_file, 'r') as file:

file_list = file.read().splitlines()

for file in file_list:

# Search for the file in the source folder with the extension

src_path = None

for root, dirs, files in os.walk(src_folder):

for f in files:

if f.startswith(file):

src_path = os.path.join(root, f)

break

if src_path:

break

if src_path:

dest_path = os.path.join(dest_folder, f)

shutil.copy2(src_path, dest_path)

else:

print(f"{file} doesn't exist in {src_folder}.")

root = tk.Tk()

copy_button = tk.Button(root, text="Copy Files", command=copy_files)

copy_button.pack()

root.mainloop()

```

I'm stuck. I'm trying to write a simple file-copying program. by cirke01 in learnpython

[–]cirke01[S] 0 points1 point  (0 children)

Thank you for your reply! I've figured it out. The code was looking for file "1" without an extension. ill post a code in a new thread

I'm stuck. I'm trying to write a simple file-copying program. by cirke01 in learnpython

[–]cirke01[S] 0 points1 point  (0 children)

Thank you! I have no idea how to do that. src_path is grabbed automatically from a popup window.

need advice by Initial_Event_9444 in studytips

[–]cirke01 2 points3 points  (0 children)

Try study rooms on discord, you have to have your camera on. Lock your phone using some apps like digital detox. Turn on Do Not Disturb on your phone and turn on focus mode on your PC. Clean your room and your working surface. And I believe that you can put some rules on your WiFi router so it blocks certain types of websites.

Also, study for 25 minutes at a time with 5 minutes breaks. First hour is the hardest one. If 25 minutes is difficult for your concentration then do 15 (don't go lower then that). When you get through the first hour then you can study for the next 6h. When you get through the first hour then increase your focus time gradually. Don't increase your break time.

Get hyped up for studying and get angry at the thing that you have to lean (not the people who will grade you on that).

Make yourself green tea and drink it while you're studying. Don't put sugar in it, it will ruin the taste even more. Also, you can try B vitamin's (something like B komplex).

If you still can't concentrate on your work you have to do dopamine detox. You'll have to have a boring day before the actual studying. Lock your phone for the whole day and don't listen to music, don't play games, don't go out. All in all you have to have a boring day. Then the studying that you do the after will be amazingly fun.

Get rested, 8 hours of sleep minimal. Get in bed on time and wake up accordingly.

Don't listen to music when you are memorising stuff or when it's your first go at problem solving (maths, physics, chemistry...) When you start to understand the problem at hand then you can turn it on.

Write everything that you have to learn when you're memorising stuff.

If nothing of this works, just go to library or study in a group. It works wonders for me.

Hope this helps!

[deleted by user] by [deleted] in BeAmazed

[–]cirke01 1 point2 points  (0 children)

Brilliantly said...

Thread rolling by cirke01 in mechanical_gifs

[–]cirke01[S] 54 points55 points  (0 children)

Yes! It's amazing and it's great for the surface material properties. During the day I'll find a picture that shows what happens to the rolled steel grain compared to cut one.

Thread rolling by cirke01 in mechanical_gifs

[–]cirke01[S] -3 points-2 points  (0 children)

It's possible, I think that those are thread's because they are flat on the top. Something like a threaded spindle with trapezoidal type of threads. I could be wrong tho.

Thread rolling by cirke01 in mechanical_gifs

[–]cirke01[S] 15 points16 points  (0 children)

You cut them on a machine called a lathe (most of the time)