Return to Snippet

Revision: 16071
at July 24, 2009 23:24 by iloveitaly


Initial Code
#!/bin/bash

SOURCE_DIR="~/Desktop/in"
SOURCE_DIR_NAME=`basename "$SOURCE_DIR"`
SUFFIX="_l"
TARGET_DIR="~/Desktop/out"

find "$SOURCE_DIR" | while read file; do
	baseName=`basename "$file"`
	
	if [[ ${baseName:0:1} == "." || "$baseName" == "$SOURCE_DIR_NAME" ]]; then
		continue
	fi
	
	NAME=`echo "$baseName" | cut -d'.' -f1`
	EXTENSION=`echo "$baseName" | cut -d'.' -f2`
	
	cp "$file" "$TARGET_DIR/$NAME$SUFFIX.$EXTENSION"
done

exit 0

Initial URL

                                

Initial Description

                                

Initial Title
Add Suffix, Retain Extension, and Copy

Initial Tags
copy, extension

Initial Language
Bash