0

2000 年に作成され、現在も維持されているサイトに多数の html ファイルがあります最近、不正な文字を HTML エンティティに置き換える取り組みを開始しました。著作権記号や商標タグを探してページを移動するのは、かなりの雑用のように思えます。大量の html ファイルを取り、違法な文字を html エンティティに置き換える必要がある場所を教えてくれるアプリを知っている人はいますか?

4

3 に答える 3

0

また、多数のファイル名を文字セット間で定期的に変換する必要がある Web サイトもあります。テキスト エディターでこれを行うことができますが、php で 2 つのステップを使用するポータブル ソリューションが望ましいとされました。まず、ファイル名を配列に追加してから、検索と置換を行います。関数内の余分なコードにより、特定のファイル タイプが配列から除外されます。

Function listdir($start_dir='.') {                                                           
  $nonFilesArray=array('index.php','index.html','help.html'); //unallowed files & subfolders 
  $filesArray = array() ; // $filesArray holds new records and $full[$j] holds names         
  if (is_dir($start_dir)) {                                                                  
    $fh = opendir($start_dir);                                                               
    while (($tmpFile = readdir($fh)) !== false) { // get each filename without its path      
      if (strcmp($tmpFile, '.')==0 || strcmp($tmpFile, '..')==0) continue; // skip . & ..    
      $filepath = $start_dir . '/' . $tmpFile; // name the relative path/to/file             
      if (is_dir($filepath)) // if path/to/file is a folder, recurse into it                 
        $filesArray = array_merge($filesArray, listdir($filepath));                          
      else // add $filepath to the end of the array                                          

      $test=1 ; foreach ($nonFilesArray as $nonfile) {                                       
        if ($tmpFile == $nonfile) { $test=0 ; break ; } }                                    
      if ( is_dir($filepath) ) { $test=0 ; }                                                 
      if ($test==1 && pathinfo($tmpFile, PATHINFO_EXTENSION)=='html') {                      
        $filepath = substr_replace($filepath, '', 0, 17) ; // strip initial part of $filepath
        $filesArray[] = $filepath ; }                                                        
    }                                                                                        
    closedir($fh);                                                                           
  } else { $filesArray = false; } # no such folder                                           
  return $filesArray ;                                                                       
}                                                                                            

$filesArray = listdir($targetdir); // call the function for this directory                   
$numNewFiles = count($filesArray) ; // get number of records                                 

for ($i=0; $i<$numNewFiles; $i++) { // read the filenames and replace unwanted characters    
  $tmplnk = $linkpath .$filesArray[$i] ;                                                     
  $outname = basename($filesArray[$i],".html") ; $outname = str_replace('-', ' ', $outname); 
}                                                                                            
于 2011-12-04T17:12:48.247 に答える
0

優れたテキスト エディタであれば、ファイルの内容を検索して、一致するもののリストを返します。

私はEditPlusでこれを行います。これを簡単に行うのに役立つNotepad++TextPadなどのエディターがいくつかあります。

ファイルを開く必要はありません。ファイルが保存されているパス、マスク (*.html)、および「©」を検索するコンテンツを指定するだけで、エディターが一致のリストを表示し、ダブルクリックするとファイルが開き、一致する行を上げます。

于 2009-11-04T15:47:40.863 に答える
0

PHP スクリプトを作成することもできますが (できれば、喜んでお手伝いします)、「特殊文字」の一部は既に変換済みであると想定しているため、作業が少し難しくなります (ただし、まだ可能だと思います)...

于 2009-11-04T15:52:49.683 に答える