Archive a folder in Bridge

Upload Adobe Bridge Scripts, Download Adobe Bridge Scripts, Support for Individual Adobe Bridge Scripts

Moderators: Tom, Kukurykus

pierrelabbe

Archive a folder in Bridge

Post by pierrelabbe »

Hi all,
On Mac or/and PC, is it possible to code a "Bridge script" that archive/compress a folder to a zip file?
thx for your help
Paul MR

Archive a folder in Bridge

Post by Paul MR »

As far as Windows goes, it is difficult to use the built in zip function. You would need C# or VB the other alternative would be to use a command line version of ZIP maybe 7-Zip http://www.7-zip.org/ then you could use the system() to send a line command?
larsen67

Archive a folder in Bridge

Post by larsen67 »

On the mac these work for me… They are for the most part the same thing… With a just a string change… You will have to wait a little while depending on the size of what you are compressing… They work for me in Bridge CS2 but if you have CS4 or 5 then you can also use them with Photoshop…

A Disk Image…
Code: Select allfunction makeDiskImage(folderObj) {
   if (folderObj instanceof Folder && folderObj.exists) {
      var sourcePath = "'" + folderObj.fsName + "'";
      var destPath = "'" + folderObj.fsName + '.dmg' + "'";
      var shellString = "hdiutil create -srcfolder ";
      shellString += sourcePath;
      shellString += " ";
      shellString += destPath;
      var x = undefined;
      var sh = app.system(shellString);
      !sh ? x = true : x = false;
      return x;
   }else{
      return false;
   }
}

A Zip…
Code: Select allfunction makeZIP(folderObj) {
   if (folderObj instanceof Folder && folderObj.exists) {
      var sourcePath = "'" + folderObj.fsName + "'";
      var destPath = "'" + folderObj.fsName + '.zip' + "'";
      var shellString = "/usr/bin/ditto -c -k -rsrc --keepParent ";
      shellString += sourcePath;
      shellString += " ";
      shellString += destPath;
      var x = undefined;
      var sh = app.system(shellString);
      !sh ? x = true : x = false;
      return x;
   }else{
      return false;
   }
}

A TAR Archive…

Code: Select allfunction makeTARarchive(folderObj) {
   if (folderObj instanceof Folder && folderObj.exists) {
      var sourcePath = "'" + folderObj.fsName + "'";
      var destPath = "'" + folderObj.fsName + '.tbz' + "'";
      var shellString = "/usr/bin/tar cjvf ";
      shellString += destPath;
      shellString += " ";
      shellString += sourcePath;
      var x = undefined;
      var sh = app.system(shellString);
      !sh ? x = true : x = false;
      return x;
   }else{
      return false;
   }
}

Never got around to see if there is a way to create a progress bar but I doubt its possible…