Scripts | Codes

All languages in three languages :-)
Showing posts with label extensions. Show all posts

Extraire des liens d'un fichier (images, pages HTML, pdf, ...) et l'affiche dans le Terminal ou les télécharger avec wget (en une seul ligne).
Vous pouvez choisir les extensions que vous voulez extraire entre les dernières parenthèses séparées par des |
Dans l'exemple on extrait les lien des images d'un fichier index.php puis on les télécharge
On utilise un RegExp de type Perl avec -P

Extract links from a file (images, HTML pages, pdf, ...) and displays them in the Terminal or downloads them with wget (in only one line of code).
You can choose which extensions you want to extract by specifying them inside the last parentheses separated by |
In the example we extract the images link to a index.php file and then downloads them
It uses a Perl-type RegExp with -P

يستخرج كل أنواع الروابط من ملف في Terminal
ثم يمكن تحميلها بإستعمال wget

يمكنك إختيار التمديدات بكتابتها بين القوسين مفصولة ب |
في هذا المثال نستخرج كل روابط الصور ثم نحملها 
يستخدم ريجيكس من نوع Perl 

Open in a new window
wget `cat index.php | grep -P -o 'http:(\.|-|\/|\w)*\.(gif|jpg|png|bmp)'`


Supprimer des virus d'un répertoire...
Utilisation:
perl rem.pl /media/diskwindows/documents exe
va enlever tout les exécutables de ce dossier (assurez vous d'avoir enlever toutes les applications .exe utiles).
Vous pouvez aussi l'appliquer avec n'importe quelle extension pour supprimer les fichiers correspondants, par éxemple pour effacer toutes les photos .jpg:
perl rem.pl /media/diskwindows/documents jpg
Attention : ne jamais l'appliquer sur un dossier système!



Remove viruses from a folder ...
Usage:
perl rem.pl /media/diskwindows/documents exe
will remove all the executables in this folder (make sure to remove all applications .exe useful from this folder).

You can apply it with any extension to delete these files, for example delete all files. Jpg:
perl rem.pl /media/diskwindows/documents jpg
Attention : ne jamais l'appliquer sur un dossier système!



إزالة الفيروسات من ملف
perl rem.pl /media/windowdisk/documents exe
‎(سيتم إزالة كافة الملفات التنفيذية في هذا المجلد )تأكد من نزع  كافة التطبيقات المفيدة 
.jpgيمكنك تطبيق ذلك مع أي تمديد لحذف هذه الملفات ، على سبيل المثال حذف كل الملفات  
perl rem.pl /home/me//documents jpg
حذاري: عدم تطبيق هذا السكريبت على مجلد نظام التشغيل 

Open in a new window
#!/usr/bin/perl 
####################################################
# find more scripts on scripts-n-codes.blogspot.com
####################################################
use strict;
use Carp;
use warnings;
my @ext = ("\.".$ARGV[1]);  # tu mets les extensions de fichiers
my $fol = $ARGV[0];  # tu mets ton répertoire
 
my @fic = ls_fic($fol);
 
foreach my $file (@fic) {
  foreach my $exs (@ext) {
    if($file =~ m{$exs$}i) {
      print "$file deleted\n";
      unlink($file);
    }
  }
}
sub ls_fic {
  my ($fol) = @_;
  my @fic = ();
  opendir (my $rep_fh, $fol) 
    or die "impossible d'ouvrir le repertoire $fol\n";
  my @file_rep = grep { !/^\.\.?$/ } readdir($rep_fh);
  closedir ($rep_fh);
  
  foreach my $nom (@file_rep) {
    if ( -f "$fol/$nom") {
      push (@fic, "$fol/$nom");  
    }
    elsif ( -d "$fol/$nom") {
      push (@fic, ls_fic("$fol/$nom"));
    }
  }
  return @fic;
}

Subscribe to: Posts (Atom)
attendez....