mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-29 18:30:09 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			31 lines
		
	
	
		
			502 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			502 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
| #!/bin/bash
 | |
| 
 | |
| shopt -s extglob
 | |
| 
 | |
| SCRIPT_DIR="`dirname $0`"
 | |
| 
 | |
| # we operate only on the dir the script is in...
 | |
| cd $SCRIPT_DIR
 | |
| 
 | |
| if ! [ -e "ALL" ] ; then
 | |
| 	mkdir "ALL"
 | |
| fi
 | |
| 
 | |
| find . -path ./ALL -prune -o -iregex ".*\(jpg\|png\|gif\)" -printf ./%P\\0 | while read -d '' f ; do
 | |
| 	echo "$f"
 | |
| 	to=${f//.\//}
 | |
| 	mv "$f" "./ALL/${to//\// - }"
 | |
| 
 | |
| 	# cleanup...
 | |
| 	while [[ $f != "." ]] ; do
 | |
| 		f=`dirname ./"$f"`
 | |
| 		f=${f//.\//}
 | |
| 
 | |
| 		if ! [ "`ls -A ./\"$f\"`" ] ; then
 | |
| 			echo "removing empty: $f"
 | |
| 			rmdir ./"$f"
 | |
| 		fi
 | |
| 	done
 | |
| done
 | |
| 
 |