-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbatch_copy.py
More file actions
48 lines (35 loc) · 1.1 KB
/
Copy pathbatch_copy.py
File metadata and controls
48 lines (35 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import pyperclip
from time import sleep
def get_clipboard_data():
data = pyperclip.paste()
return data
def copy_to_clipboard(content):
pyperclip.copy(content)
def clear_clipboard():
pyperclip.copy('')
def batch_copy():
content_list = []
# Clears the clipboard
clear_clipboard()
# Clears file
open('batch_copy.txt', 'w').close()
print("Batch Copy Started")
while True:
# Opens file for appending
with open('batch_copy.txt', 'a+') as file:
content = get_clipboard_data()
if content:
content_list.append(content)
file.write(content + '\n')
clear_clipboard()
print(content_list)
print("Batch Copy Ended")
with open('batch_copy.txt', 'r') as file:
file_content = file.read()
copy_to_clipboard(file_content)
# # Add spaces to each copied block
# content_list = [x + ' ' for x in content_list]
# # Join all blocks together
# content_list = ''.join(content_list)
# # Insert into clipboard
# copy_to_clipboard(content_list)