Commit cf25c7bad7

cf25c7bad755a7b79596721ab36f551f4d8107bf

parent: 66dea52d21

Unsigned

cmc <hello@cleberg.net> · 2025-02-25 02:59 UTC

fix indentation in email-migration post

Layout: unified · split

content/blog/2025-02-24-email-migration.org +19 −18
@@ -83,23 +83,23 @@ import shutil
8383
8484# Loop through all files in the current folder
8585for file in glob.glob("*.eml"):
86 # Create boolean to check if we should move the file
87 move = False
86 # Create boolean to check if we should move the file
87 move = False
8888
89 # Open the current file
90 f = open(file, 'r')
89 # Open the current file
90 f = open(file, 'r')
9191
92 # For each line in file, find the From header
92 # For each line in file, find the From header
9393 for line in f:
9494 if line.startswith("From:"):
95 # If we find ourself, mark the message for move
95 # If we find ourself, mark the message for move
9696 if "user@example.com" in line:
9797 move = True
9898
9999 # Close the file
100 f.close()
100 f.close()
101101
102 # Move the file, if marked for move
102 # Move the file, if marked for move
103103 if move == True:
104104 filepath = os.path.join("/Users/YOUR_USERNAME/.maildir/migadu/Archive/cur/", file)
105105 new_filepath = os.path.join("/Users/YOUR_USERNAME/.maildir/migadu/Sent/cur/", file)
@@ -164,24 +164,24 @@ import shutil
164164
165165# Loop through all files in the sub-folders under Archive
166166for file in glob.glob("*.eml"):
167 # Create boolean to check if we should move the file
168 move = False
167 # Create boolean to check if we should move the file
168 move = False
169169
170 # Open the current file
170 # Open the current file
171171 f = open(file, 'r')
172172
173 # For each line in file, find the X-Pm-Date header
173 # For each line in file, find the X-Pm-Date header
174174 for line in f:
175175 if line.startswith("X-Pm-Date"):
176 # Split the line into a list by spaces;
177 # Then select the item that contains the year
176 # Split the line into a list by spaces;
177 # Then select the item that contains the year
178178 year = line.split(" ")[4]
179179 move = True
180180
181181 # Close the file
182 f.close()
182 f.close()
183183
184 # Move the file, if marked for move
184 # Move the file, if marked for move
185185 if move == True:
186186 filepath = os.path.join("/Users/YOUR_USERNAME/.maildir/migadu/Archive/cur/", file)
187187 new_filepath = os.path.join(f"/Users/YOUR_USERNAME/.maildir/migadu/Archive/{year}/cur/", file)
@@ -220,9 +220,10 @@ import shutil
220220
221221# Loop through all files in the sub-folders under Archive
222222for file in glob.glob("*/cur/*"):
223 # Remove the characters at the end of the file name created by =mu=
223 # Remove the characters at the end of the file name created by =mu=
224224 new_file = file.split(",U=",1)[0]
225 # Move the file to the new file name
225
226 # Move the file to the new file name
226227 shutil.move(file, new_file)
227228#+end_src
228229