2024-02-26 17:32:51 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								##!/bin/bash
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-27 18:30:05 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-02-25 19:38:14 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# If there are images in img/ that are not being used by the Zettelkasten, delete them
							 | 
						
					
						
							
								
									
										
										
										
											2024-02-26 17:42:06 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-02-26 19:06:05 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# Loop through /img directory
							 | 
						
					
						
							
								
									
										
										
										
											2024-03-01 09:02:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								find "/home/thomas/repos/eolas/img" -type f | while read filename; do
							 | 
						
					
						
							
								
									
										
										
										
											2024-02-26 19:06:05 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										# Check each .md file in ZK for image   
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										search_result=$(rg "${filename##*/}" "${EOLAS_PATH}/zk" --type markdown)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    # If the image is not found in any file, delete it
							 | 
						
					
						
							
								
									
										
										
										
											2024-02-26 17:32:51 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if [ -z "$search_result" ]; then
							 | 
						
					
						
							
								
									
										
										
										
											2024-02-26 17:42:06 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
												echo "Deleted unused image: ${filename##*/}"
							 | 
						
					
						
							
								
									
										
										
										
											2024-03-01 09:02:37 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        rm $filename
							 | 
						
					
						
							
								
									
										
										
										
											2022-12-27 18:30:05 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    fi
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								done
							 | 
						
					
						
							
								
									
										
										
										
											2024-02-26 17:32:51 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 |