mirror of
				https://github.com/kevinveenbirkenbach/directory-content-scanner.git
				synced 2025-11-04 03:48:22 +00:00 
			
		
		
		
	Added the option to pass multiple directories
This commit is contained in:
		
							
								
								
									
										26
									
								
								scan.sh
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								scan.sh
									
									
									
									
									
								
							@@ -1,16 +1,8 @@
 | 
				
			|||||||
#!/bin/bash
 | 
					#!/bin/bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Check if a directory argument is provided
 | 
					# Check if at least one directory argument is provided
 | 
				
			||||||
if [ "$#" -ne 1 ]; then
 | 
					if [ "$#" -lt 1 ]; then
 | 
				
			||||||
    echo "Usage: $0 <directory>"
 | 
					    echo "Usage: $0 <directory1> [<directory2> ...]"
 | 
				
			||||||
    exit 1
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
DIR="$1"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Ensure the directory exists
 | 
					 | 
				
			||||||
if [ ! -d "$DIR" ]; then
 | 
					 | 
				
			||||||
    echo "Error: $DIR is not a valid directory."
 | 
					 | 
				
			||||||
    exit 1
 | 
					    exit 1
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -28,5 +20,13 @@ function scan_and_print() {
 | 
				
			|||||||
    done
 | 
					    done
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Start the scan from the given directory
 | 
					# Loop through all provided directories and start the scan
 | 
				
			||||||
scan_and_print "$DIR"
 | 
					for DIR in "$@"; do
 | 
				
			||||||
 | 
					    # Ensure the directory exists
 | 
				
			||||||
 | 
					    if [ ! -d "$DIR" ]; then
 | 
				
			||||||
 | 
					        echo "Error: $DIR is not a valid directory."
 | 
				
			||||||
 | 
					        exit 1
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    scan_and_print "$DIR"
 | 
				
			||||||
 | 
					done
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user