Small Issue with Compress Statement


#1

I’m having an issue with the ‘compress’ statement that I can’t seem to resolve. When I set a path that’s just a folder in the same folder as the file I’m trying to compress, then compress using this path, the compress statement does the compression, but it includes all of the enclosing folders all the way back to my user folder (e.g., “/User/jcrunch/Documents/Panorama DBs/eXPRS X/Client Hours - eXPRS X Ferd/Client Hours - eXPRS.pandb”). This is very confusing to those who have to install these files. Is there a parameter or setting I’m missing here?

Here’s the code, with names changed to protect the guilty:

local counter,manarr,thismgr,thispath

counter=1

manarr="Zeke,zeke@mycompany.com"+cr()+
"Biff,biff@mycompany.com"+cr()+
"Muffy,muffy@mycompany.com"+cr()+
"Ferd,ferd@mycompany.com"+cr()+
"Clyde,clyde@mycompany.com"+cr()+
"Skarsky,skarsky@mycompany.com"

loop
thismgr=array(mgrch,counter,¶)
thispath=info(“databasename”)+" “+thismgr
select Manager=thismgr
removeunselected
saveacopyas thispath+”/"+info(“databasename”)+".pandb"
compress thispath

importtext fileload("/Originaltextfilepath/Originaltextfile.txt"), “ExistingData”, “Replace”

counter=counter+1

until counter>mgrchsize //set in prior code; not at issue here


#2

It is exhibiting another, equally confusing behavior: It is saving a second folder, containing an older version of the database, in the compressed folder. Here’s a screenshot of one of the compressed folders, uncompressed:


#3

…and here’s a screenshot of the actual folder contents:


#4

Okay, never mind the second issue, about the older version of the database in a separate folder. In the code I posted I had forgotten to fully select the manager’s name out of the array.

thismgr=array(mgrch,counter,¶)

should have been

thismgr=array(array(mgrch,counter,¶),1,",")

I still can’t figure out the inclusion of all of the enclosing folders, though.


#5

Depending on the type of compression you choose, Panorama uses either the zip or tar command line programs to do compression. These programs are included with macOS (and also Linux and UNIX computers). Unfortunately, the behavior you are describing is how these programs work when compressing a folder. I could hardly believe this myself when I discovered this, and spent many hours trying to figure out how to get them to not do that. However, I was unsuccessful. It appears that this is intentional, I guess the idea is that you’ll be able to put items back in their original locations. I’m using compression in Panorama X Server, and wound up writing some complex code to uncompress these archives the way I wanted to (the code is specific to my application, so I’m not going to post it, not sure if it could be made general purpose or not).

Bottom line, you’re not confused, that is how it works.


#6

After playing around searching online and in the Terminal I found what Apple supposedly uses for the compression scheme used in the Finder. This is what you get if you select Compress in the Finder.

ditto -ck --rsrc --sequesterRsrc folder file.zip

Try as I may however, I can’t get it to work in Panorama using a shellscript command. It does work in the Terminal on the command line if I first do a cd to the proper parent folder. Trying to put the path to that folder all on the ditto command line does not seem to work. My head hurts so I’m giving up.:disappointed_relieved:


#7

Thanks for the info and the efforts, Gary and Jim. Weird.


#8

I got this to work by putting the cd into the same shellscript command as the ditto, with a semicolon separating them.

shellscript |||cd ~/Desktop;ditto -ck --rsrc --sequesterRsrc test test.zip|||

#9

How did you figure that out? Very clever.

The ditto shell command is very unusual in that it is unique to Apple systems. Normally on UNIX and Linux systems the cp command is used for copying files and folders. The cp command is also available in macOS, but it doesn’t know anything about unique Apple features like resource forks, type/creator codes, and other features unique to the Mac. So Apple developed the ditto command as an alternative to cp for OS X systems, and that has been the preferred method for copying files and folders from the command line since OS X came out. I’ve used this command many times, but I had no idea it had compression built in. Silly me – I see it’s in the man page. However, there is no reference to ditto on the zip or unzip man pages, so that’s why I missed it. Never even thought to look at ditto. Good find Gary :slight_smile:


#10

I think you might be able to replace the above code with the following code:

thispath=unixshellstring(thispath)
shellscript {cd ~/Documents/Panorama\ DBs/eXPRS\ X;ditto -c -k --sequesterRsrc --keepParent }+thispath+{ }+thispath+{.zip}

This should create a proper zip file with only the chosen folder and its contents. Thanks to Dave for setting me straight on how to combine the cd and ditto commands in the shellscript. For some reason I was trying to use the | (vertical line character) to link the two commands together. I guess I should of checked the proper syntax but it was late in my day and I was out of patience.


#11

Thanks, Gary! That solved the problem (after I reversed the unixshellstring on the file path later on in the procedure, where I needed a straight Mac file path using that variable; had me scratching my head for a minute).