Created
July 4, 2020 04:31
-
-
Save gfxhacks/cf4d296528ddb03cbff427455842079a to your computer and use it in GitHub Desktop.
Snippets to extract path, filename, and extension from a full path input in bash. More info: https://gfxhacks.com/renaming-files-by-date-from-metadata/#extracting-path-filename-and-extension
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
FILEPATH=`dirname path/to/file.ext` | |
# returns: path/to | |
FILENAME=`basename path/to/file.ext` | |
# returns: file.ext | |
FILENAME=`basename path/to/file.ext | rev | cut -d . -f 2- | rev` | |
# returns: file | |
FILEEXT=`rev <<< path/to/file.ext | cut -d . -f 1 | rev` | |
# returns: ext |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment