Speed Posted October 30, 2006 Report Share Posted October 30, 2006 tatad folderii dem_zip ir sadi faili! dfs-0610301425-awp_map5.dem dfs-0610301404-de_aztec.dem dfs-0610292249-fy_pool_day.dem dfs-0610290455-cs_bank3.dem utt kaa ar php uztaisit lai izdzesas tie faili kam textaa 0610290455 ir 29 ! palidzat ja tas ir iespejams plz! Link to comment Share on other sites More sharing options...
black Posted October 30, 2006 Report Share Posted October 30, 2006 Nebuus saistiits tieshi ar PHP, bet ar programmeeshanu kaa taadu: sheema sekojosha - 1) nolasaam foldera failu nosaukumus, ieliekam tos nosaukumus kaut kaadaa masiivaa 2) peec tam braucam cauri masiivam, un chekojam, vai tekstaa ir "29" 3) ja ir, izsaucam unlink. PHP manuaali var atrast sadalju par masiiviem (arrays), ar to vari saakt. Par unlink funkciju, raadaas, Tu jau zini. Protams, jebkursh to programmu var uzrakstiit kaadas minuutes laikaa, bet tad jau Tev vairs nebuus interesanti. Link to comment Share on other sites More sharing options...
koko Posted October 30, 2006 Report Share Posted October 30, 2006 (edited) Nu jaa :) Teorija jau viegla Karoche - ja php5, tad ielasam saturu ar scandir (vai kaut kas tamliidziigs) masiivaa 2) ejam pa masiivu un ar preg_match atrodam vajadziigo (neesmu profesionaalis, taapeec varu tikai mineet kodu if (preg_match('/.*29.*/' $val)) unlink($val); Nu kaut kas tml... Vot regulaaraa izteiksme gan jau klibo nenormaali - kaa jau teicu - ar taam man saskarsme maza :) Edited October 30, 2006 by koko Link to comment Share on other sites More sharing options...
Delfins Posted October 30, 2006 Report Share Posted October 30, 2006 black, Nafig glabāt masīvā? Uzreiz vai tad pa taisno nevar nočekot? Link to comment Share on other sites More sharing options...
black Posted October 30, 2006 Report Share Posted October 30, 2006 Tāpēc, lai būtu reuseable kods. Vinjsh varees uztaisiit metodi readDir(), kas atgriez masiivu ar failu vaardiem direktorijaa, un peec tam to izmantot daudz un dazaados veidos savos naakamajos projektos :) Link to comment Share on other sites More sharing options...
Speed Posted October 30, 2006 Author Report Share Posted October 30, 2006 <?php if ($handle = opendir('C:/AppServ/www/demo_zip/')) { while (false !== ($file = readdir($handle))) { $fails = fopen('fails.txt', 'a',); $text = " $file"; fwrite($fails, $text); fclose($fails); $arr file("fails.txt",'a') if (preg_match('/.*29.*/' $val)) unlink($val); }; }; ?> uzrakstiju shadu codu varbut tas ir nepareizi negribu lai izdzesas visi faili tapec negribas pasham parbaudt ! Link to comment Share on other sites More sharing options...
andrisp Posted October 30, 2006 Report Share Posted October 30, 2006 (edited) Nu un ko tagad iesāksim ? Taču nobakupo failus un pamēģini. ;) Edited October 30, 2006 by andrisp Link to comment Share on other sites More sharing options...
Speed Posted October 30, 2006 Author Report Share Posted October 30, 2006 es bik palaboju codu <?php if ($handle = opendir('C:/AppServ/www/demo_zip/')) { while (false !== ($file = readdir($handle))) { $fails = fopen('fails.txt', 'a'); $text = " C:/AppServ/www/demo_zip/$file"; fwrite($fails, $text); fclose($fails); $arr = file("fails.txt", 'a'); if (preg_match('/.*29.*/', $text)) unlink($text); }; }; ?> bet radas sitads suds == Warning: unlink( C:/AppServ/www/demo_zip/dfs-0610290023-de_box.dem.zip): Invalid argument in c:\appserv\www\delzip.php on line 10 Link to comment Share on other sites More sharing options...
v3rb0 Posted October 30, 2006 Report Share Posted October 30, 2006 komatus tik vispirms saliec. Link to comment Share on other sites More sharing options...
andrisp Posted October 30, 2006 Report Share Posted October 30, 2006 Tāpēc, ka tev $text sākumā ir /n characters, respektīvi, pārnesums jaunā rindiņā. Raksti: $text = "C:/AppServ/www/demo_zip/$file"; fwrite($fails, "\n".$text); Link to comment Share on other sites More sharing options...
Delfins Posted October 30, 2006 Report Share Posted October 30, 2006 pareizāk ir: $pattern = '/[.]{4}29.*/'; Citādi pēc jūsu .*29.* izdzēsīs ne to ko vajag... PS: ja 29 domāts ir tikai `datums` Link to comment Share on other sites More sharing options...
Speed Posted October 30, 2006 Author Report Share Posted October 30, 2006 tnx tag sanaca bet vai nevar uztaisit lai man ik pa laikam nebutu japieraksta piem no 29 uz 30 no 30 uz 31 utt <?php $i = "27"; if ($handle = opendir('C:/AppServ/www/demo_zip/')) { while (false !== ($file = readdir($handle))) { $fails = fopen('fails.txt', 'a'); $text = "C:/AppServ/www/demo_zip/$file"; fwrite($fails, "\n".$text); fclose($fails); $arr = file("fails.txt", 'a'); $i++; if (preg_match('/.*$i.*/', $text)) unlink($text); }; }; ?> meginaju sita bet nesanaca ! Link to comment Share on other sites More sharing options...
Delfins Posted October 30, 2006 Report Share Posted October 30, 2006 (edited) Speed. blin, konkretizējies!... $i = rand(0,30); Kļuda ir šeit -->> '.*$i.*' Edited October 30, 2006 by Delfins Link to comment Share on other sites More sharing options...
andrisp Posted October 30, 2006 Report Share Posted October 30, 2006 Mācies pamatus. 1) lai mainīgais nopārsētos teksta stringā, tad strings jāievieto dubultpēdiņās ("), 2) Tikpat labi, tu vari to $i uzreiz nodefināt 28, 3) aiz } nav jēgas likt ; Link to comment Share on other sites More sharing options...
Speed Posted October 30, 2006 Author Report Share Posted October 30, 2006 vajag shitaa ? if (preg_match('/.*"$i".*/', $text)) unlink($text); Link to comment Share on other sites More sharing options...
Recommended Posts