RE: [PHP-DB] Renaming files after a name in a db field possible?
| From: | Beau Lebens | Date: | Thu, 14 Mar 2002 00:08:31 +0000 |
| Subject: | RE: [PHP-DB] Renaming files after a name in a db field possible? | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-17662@lists.php.net to get a copy of this message | ||
andy, this should be pretty basic - just try something along the lines of
1. SELECT country/codes from DB [1]
2. loop thru those results [2]
a. check if a file called "country code"-map.gif exists[3], if it
does,
rename[4] it to matching "country name"-map.gif
b. if not, output (so you know what has and hasn't worked)
3. done
useful functions
[1] mysql_query("SELECT * FROM countries ORDER BY country_code");
[2] while ($thisCountry = mysql_fetch_array($result)) {
[3] if (file_exists($thisCountry["country_code"] . "-map.gif")) {
[4] rename($thisCountry["country_code"] . "-map.gif",
$thisCountry["country"] . "-map.gif");
HTH
Beau
// -----Original Message-----
// From: Andy [mailto:news.letters@gmx.de]
// Sent: Wednesday, 13 March 2002 8:47 PM
// To: php-db@lists.php.net
// Subject: [PHP-DB] Renaming files after a name in a db field possible?
//
//
// Hi there,
//
// I am wondering if this is possible in php:
//
// I have a whole bunch of files named after countrycodes. E.g.
// CA-map.gif
//
// Now I would like to rename those files after the country.
// This is listed in
// a dbtable containing the countrycode and countryname. E.g.
// CA - Canada
//
// How could I generate a php script which scannes the dir for matching
// Countrycode patterns and renames the filename ?
// E.g.: Make out of CA-map.gif -> canada-map.gif?
//
// Thanx for any hint,
//
// andy
//
//
//
// --
// PHP Database Mailing List (http://www.php.net/)
// To unsubscribe, visit: http://www.php.net/unsub.php
//