Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action proposal: Compress Without Meta #232

Open
jd-solanki opened this issue Feb 29, 2024 · 0 comments
Open

Action proposal: Compress Without Meta #232

jd-solanki opened this issue Feb 29, 2024 · 0 comments

Comments

@jd-solanki
Copy link

jd-solanki commented Feb 29, 2024

Description

Hi 馃憢馃徎

I'm fan of you work. Recently, I was developing Action that compresses the files & folders like mac's native compress feature (when we right click on files and directories) without meta directories like __MACOSX and .DS_Store. I created myself but somehow it doesn't work on Documents & Downloads dir and don't know how to resolve it.

But Why?

When we send zip to non-mac users they get unwanted __MACOSX and .DS_Store directories.


Hence, I'm raising this feature request in this actions to get them as a package.

Here's my existing work of shell script:

# Function to create zip file name based on inputs
create_zip_name () {
    if [ "$#" -eq 1 ]; then
        # Single file or directory
        inputPath="$1"
        inputBaseName=$(basename "$inputPath")

        if [ -d "$inputPath" ]; then
            echo "${inputBaseName}.zip"
        elif [ -f "$inputPath" ]; then
            echo "${inputBaseName%.*}.zip"
        fi
    else
        # Multiple files or directories
        echo "Archive.zip"
    fi
}

# Initial directory and zip file setup
initialDir=$(dirname "$1")
cd "$initialDir"
zipFileName=$(create_zip_name "$@")

# Execute zip command excluding unwanted metadata files
zip -r "$zipFileName" "${@#$initialDir/}" -x '**/__MACOSX' -x '**/.DS_Store'

# Use AppleScript to select the ZIP file in Finder
osascript -e 'tell application "Finder"' -e "activate" -e "select POSIX file \"$(pwd)/$zipFileName\"" -e 'end tell'
Screenshot

Screenshot 2024-02-29 at 11 36 07鈥疉M

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant