Last active
February 24, 2016 09:47
-
-
Save juanghurtado/211a83025fae8a2cc5a9 to your computer and use it in GitHub Desktop.
Move a film file, leaving a symlink behind. Example: "Sample film (1992) [garbage text].mkv" to "$TARGET_FOLDER/Sample film (1992).mkv"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
FILE_PATH=$1 | |
FILE_NAME=$(echo "$FILE_PATH" | sed 's:.*/::') | |
FILM_NAME=$(echo $FILE_NAME | sed 's/\[.*$//' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') | |
FILE_EXTENSION="${FILE_NAME##*.}" | |
TARGET_FOLDER=/storage/films | |
TARGET_FILE_NAME=$(echo $FILM_NAME.$FILE_EXTENSION) | |
TARGET_PATH="$TARGET_FOLDER/$TARGET_FILE_NAME" | |
mv "$FILE_PATH" "$TARGET_PATH" | |
ln -s "$TARGET_PATH" "$FILE_PATH" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment