Jump to content

Help with .lzfse Workflow?


Recommended Posts

I've created a Workflow to extract the contents of .lzfse files, however I need help:

  1. getting the original file extension of the compressed file
  2. appending it to the extracted file
  3. 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
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.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...