I needed to quickly set up a new project in BBedit that reflected a folder's complete directory structure. I wrote this and ran it inside the directory as the file index_bb.php. It outputs an applescript that I then run with an empty project window open in BBEdit. It creates all of the folders/sub-folders and then all of the shortcuts to the files. Hope it's handy for someone.
<?php #######COPY FULL PATH IN BBEDIT # ftp://name:[email protected]/target_directory/ $mpth="ftp://name:[email protected]/target_directory/"; $outs=""; $dirs_s = shell_exec('find . -type d'); $dirs=explode("\n",$dirs_s); natcasesort($dirs); foreach($dirs as $dir){ $car="tell project document 1 to "; $di=explode("/",$dir); $lt=count($di);$ct=1; foreach($di as $d){ if($d != "."){ $ct++; if($ct==$lt){ $car.='make new project collection with properties {name:"'.$d.'"}';} else{ $car.='tell project collection "'.$d.'" to ';}}} if($d !=null){ if($car !="tell project document 1 to "){$outs.=$car."\n";}}} ############## $touts=""; $dirs_s = shell_exec('find . -type f'); $dirs=explode("\n",$dirs_s); natcasesort($dirs); foreach($dirs as $dir){ $ftp=str_replace("./", $mpth, $dir); $xx =explode("/",$dir); $name=array_pop($xx); if($name!='' && (preg_match('/(.swf|.jp(.*?)g|.gif|.flv|.ico| index_bb.php)/i', $name)) ==0){ $mar="tell project document 1 to "; $di=explode("/",$dir);$lt=count($di);$ct=1; foreach($di as $d){ if($d != "."){$ct++; if($ct==$lt){ $mar.='make new project item with properties {URL:"'.$ftp.'", name:"'. $name.'"}';}else{ $mar.='tell project collection "'.$d.'" to ';}}} if($d !=null){$touts.=$mar."\n";}}} #print $touts; ############## $scr=<<<END tell application "BBEdit" END; $scr.=$outs; #$scr.="\n\n display dialog \"Begin Files in 3 seconds\" giving up after 3 \n\n"; $scr.=$touts; $scr.=<<<END end tell tell application "BBEdit" to tell project document 1 to activate END; #echo "<pre>".$scr."</pre>"; outoscr($scr); ##################### function outoscr($scr){ header("Content-Type: plain/scpt"); header("Content-Disposition: Attachment; filename=bb_proj.scpt"); header("Pragma: no-cache"); echo $scr; } ?> -- You received this message because you are subscribed to the "BBEdit Talk" discussion group on Google Groups. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at <http://groups.google.com/group/bbedit?hl=en> If you have a feature request or would like to report a problem, please email "[email protected]" rather than posting to the group. Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>
