Chris Messina Posted December 6, 2022 Share Posted December 6, 2022 I've created a Workflow to extract the contents of .lzfse files, however I need help: getting the original file extension of the compressed file appending it to the extracted file bonus: prettify and sort the contents of any .json files Here's my script (/bin/zsh) so far: # filepaths from ARGV for file in $@; do # Extract the filename without the extension filename=${file%.lzfse} # Extract the contents of the lzfse file lzfse -decode -i "$file" -o "$filename" done For the JSON transformation, I typically open the file in Atom (RIP) and run the "JSONify JavaScript Object Literal and Sort and Prettify" command in the Pretty JSON package, and then open the results in TextBuddy to Sort Ascending (Ignoring Case). I'd love to be able to use a Universal Action to do all of this! Link to comment
Chris Messina Posted December 6, 2022 Author Share Posted December 6, 2022 Here's the Workflow in case this helps: https://github.com/chrismessina/alfred-lzfse-toolkit Link to comment
vitor Posted December 6, 2022 Share Posted December 6, 2022 2 hours ago, Chris Messina said: getting the original file extension of the compressed file file='/PATH/TO/FILE.lzfse' file_extension=".${file##*.}" # ".lzfse" | Remove the first "." if you do not want it included file_no_extension="${file%.*}" # "/PATH/TO/FILE" Note file_extension isn’t resilient to paths without a .. To handle that case: file_extension="$([[ "${file}" == *.* ]] && echo ".${file##*.}" || echo '')". 2 hours ago, Chris Messina said: appending it to the extracted file "${filename}${file_extension}" # If you kept the "." in file_extension "${filename}.${file_extension}" # If you did not 2 hours ago, Chris Messina said: bonus: prettify and sort the contents of any .json files I’ll put this on the list for Automation Tasks. Chris Messina 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now