acdsee8,打开psd文件所在文件夹,全选所有psd文件,右健-〉工具-〉文件格式转换
fireworks8文件-〉批处理
fireworks的批处理在处理psd文件导出为jpg的时候,总是弹出字体不存在要你确认的对话框
acdsee则不会。



<?php
return; //2006-04-10
/*
批量处理,将psd文件都放到指定目录
*/
class batchFile{
var $version='0.2' // 此版本修改了算法,使dir列表和file列表均为相对于path /fd/fdsf/fds.txt.....
var $path=null;
var $deepLimit = 0;//目录深度,为1,表示第一层。
var $filterPath=''; //过滤的目录
var $ignoreFile = ''; //过滤的文件
var $extname=null;  //有效文本文件的扩展名。

var $dir=array();
var $file=array();


function start(){

 $current = $this->path; 
 //\0、\a、\b、\f、\n、\r、\t 和 \v
 $current = str_replace("\\", "/", $current);
 $current = preg_replace("/\/+/", "/", $current);
 $current = preg_replace("/\/$/", "", $current);

 $this->path = $current;
 if(!is_dir($current)){
  echo "<h1><font color=red>you must set the right dir</font></h1>\n";
  return;
 }
 $this->execute();
}

/** 函数 execute( $dirName = null )
* 功能 对目录下所有文件及子目录下所有文件进行操作
* 参数 $dirName 目录名称
*/
function execute( $dir ='', $dirdeep = 1)
{
$dirName = $this->path.$dir;

if( empty( $dirName ) )
exit( "IBFileSystem: directory is empty." );

if( is_dir( $dirName ) )
{
if( $dh = opendir( $dirName ) )
{
while( ( $file = readdir( $dh ) ) !== false )
{
if( $file != "." && $file != ".." )
{
$filePath = $dir . "/" . $file;
$fileAbsPath = $this->path . $filePath;
//echo $dir."<br>";
if( is_dir( $fileAbsPath ) )//为目录,递归
{
 $this->dir[]=$filePath;
 $nextDeep = $dirdeep+1;
 if ( $this->deepLimit ==0 || $nextDeep<=$this->deepLimit)
 {
  $pos = strpos($this->filterPath,$file);
  //echo $filePath."<br>";
  if ($pos===false) {
   $this->execute( $filePath , $nextDeep);  
  }
 }
}
else//为文件,进行处理

 //如果包括全部文件
 if ($this->extname=="*") {
  $this->file[]=$filePath;
 }
 else {
  $dotpos = strrpos($file,".");
  if ($dotpos!==false) {
   $extname = substr( $file,$dotpos+1);
   $pos = strpos( $this->extname , ";".$extname.";" );
   if ($pos!==false) {
    $this->file[]=$filePath;   
   }
  }    
 }   

} //文件处理结束
}
}
closedir( $dh );

}
else
{
exit( "IBFileSystem: can not open directory $dirName.");
}

//返回当前的$tree
//return $tree;
}

else
{
exit( "IBFileSystem: $dirName is not a directory.");
}
}//</listDirTree>

/**
* mkdirp is used to instead of mkdir ,mkdirp can create deep multiple directory.
*/
function mkdirp($target) {
  // If the path already exists && is a directory, all is well.
  // If the path is not a directory, we've a problem.
  if (file_exists($target)) {
   if (!is_dir($target)) return false;
   else return true;
  }

  // Attempting to create the directory may clutter up our display.
  if ( @mkdir($target) ) return true;

  // If the above failed, attempt to create the parent node, then try again.
  if ( $this->mkdirp(dirname($target)) ) return $this->mkdirp($target);

  return false;
}//</function mkdirp>


}// end class

require_once("echo.php");


$fl = new batchFile();
$fl->extname ="*"; //the file type need to be operated
$fl->deepLimit = 0;
$fl->path='D:\web\mambog_corp\模版-html\psd'; //operate dir
$fl->filterPath='_vti_cnf';  //ignored dir
$fl->start();

$outpath = 'D:/web/mambog_corp/模版-html/psdout/';

foreach ($fl->file as $file) {
 $path_parts = pathinfo($file);
 if( $path_parts["extension"] =='url' || $path_parts["extension"] =='txt'){
  unlink($fl->path.$file);
 }else {
     $nfile = str_replace("/","_",$file);
  $nfile = $outpath.$nfile;
  //echo $nfile."<br>\n";
  rename( $fl->path.$file, $nfile);
 }
}

//prt($fl);

?>

Posted on 2006-04-10 13:25  古代  阅读(900)  评论(1编辑  收藏  举报