Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 06-04-2008, 01:22 AM   #1
bigalownz
Confirmed User
 
bigalownz's Avatar
 
Industry Role:
Join Date: Aug 2005
Location: NEW ZEALAND
Posts: 1,657
changing the date of a file on a webserver

I got 10000's html files hosted that where from 2004 to 2006 etc

is there a script or programe i can use to change the 10000's html files date from 2005/2006 to 2008

thanks

i found a lot of file date changers on google but they only work with windows
__________________
$100 free credit for all hosting needs

Last edited by bigalownz; 06-04-2008 at 01:24 AM..
bigalownz is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-04-2008, 03:24 AM   #2
testpie
Mostly retired
 
testpie's Avatar
 
Industry Role:
Join Date: Apr 2006
Location: UK
Posts: 3,231
Quote:
Originally Posted by bigalownz View Post
I got 10000's html files hosted that where from 2004 to 2006 etc

is there a script or programe i can use to change the 10000's html files date from 2005/2006 to 2008

thanks

i found a lot of file date changers on google but they only work with windows
If you're using *NIX (UNIX/Linux) like I assume, couldn't you write a simple PHP script that just rips through all the files in the directory, opens them and then saves them all, changing the modified time to the day the script was run on?
__________________

Affiliates: DogFart ~ Domain parking: NameDrive ~ Traffic broker: Traffic Holder
testpie is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-04-2008, 05:14 AM   #3
bigalownz
Confirmed User
 
bigalownz's Avatar
 
Industry Role:
Join Date: Aug 2005
Location: NEW ZEALAND
Posts: 1,657
Quote:
Originally Posted by testpie View Post
If you're using *NIX (UNIX/Linux) like I assume, couldn't you write a simple PHP script that just rips through all the files in the directory, opens them and then saves them all, changing the modified time to the day the script was run on?
yes thats what im looking for
but i dont know how to write a php script like that
__________________
$100 free credit for all hosting needs
bigalownz is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-04-2008, 05:57 AM   #4
testpie
Mostly retired
 
testpie's Avatar
 
Industry Role:
Join Date: Apr 2006
Location: UK
Posts: 3,231
Quote:
Originally Posted by bigalownz View Post
yes thats what im looking for
but i dont know how to write a php script like that
Here you go, just remember to change the DIR_HERE to the directory the files are in (e.g. /home/user/public_html/filedirectory/):
PHP Code:
<?php
## Variables
# Directory
$dir "DIR_HERE";

## Code
if($handle opendir($dir)) {
 print 
"<p>Processing files...</p>";
 
# Loop through files in dir
 
while(false !== ($file readdir($handle))) {
  
# Get file data
  
$data file_get_contents($file);
  
# Write data back to file
  
$fp fopen($file"w");
  
fwrite($fp$data);
  
fclose($fp);
  
# Give output
  
print "<p>Done &quot;".$file."&quot;</p>";
 }
 
# Close dir
 
closedir($handle);
}
print 
"<br /><p>Finished</p>"
?>
__________________

Affiliates: DogFart ~ Domain parking: NameDrive ~ Traffic broker: Traffic Holder
testpie is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-04-2008, 06:06 AM   #5
Spudstr
Confirmed User
 
Spudstr's Avatar
 
Industry Role:
Join Date: Jan 2003
Location: In a Tater Patch
Posts: 2,321
you can use the system command touch to change the timestamp on a file as well. no need to use all the resources to open/close a file.
__________________
Managed Hosting - Colocation - Network Services
Yellow Fiber Networks
icq: 19876563
Spudstr is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-04-2008, 06:27 AM   #6
gornyhuy
Chafed.
 
gornyhuy's Avatar
 
Join Date: May 2002
Location: Face Down in Pussy
Posts: 18,041
Yeah, touch is way more efficient and is designed to do exactly what you want.
__________________

icq:159548293
gornyhuy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-04-2008, 07:17 AM   #7
bigalownz
Confirmed User
 
bigalownz's Avatar
 
Industry Role:
Join Date: Aug 2005
Location: NEW ZEALAND
Posts: 1,657
Quote:
Originally Posted by testpie View Post
Here you go, just remember to change the DIR_HERE to the directory the files are in (e.g. /home/user/public_html/filedirectory/):
PHP Code:
<?php
## Variables
# Directory
$dir "DIR_HERE";

## Code
if($handle opendir($dir)) {
 print 
"<p>Processing files...</p>";
 
# Loop through files in dir
 
while(false !== ($file readdir($handle))) {
  
# Get file data
  
$data file_get_contents($file);
  
# Write data back to file
  
$fp fopen($file"w");
  
fwrite($fp$data);
  
fclose($fp);
  
# Give output
  
print "<p>Done &quot;".$file."&quot;</p>";
 }
 
# Close dir
 
closedir($handle);
}
print 
"<br /><p>Finished</p>"
?>
thanks for your help
will it change the date on all files?
as i just want .html to change
__________________
$100 free credit for all hosting needs
bigalownz is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-04-2008, 07:22 AM   #8
darksoul
Confirmed User
 
darksoul's Avatar
 
Join Date: Apr 2002
Location: /root/
Posts: 4,997
go to the directory where the files are and run this command (ssh)
Code:
find . -name "*.html" -print0|xargs -0 touch

P.S. the php script above changes all files regardless of extension
__________________
1337 5y54|)m1n: 157717888
BM-2cUBw4B2fgiYAfjkE7JvWaJMiUXD96n9tN
Cambooth
darksoul is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-04-2008, 07:57 AM   #9
testpie
Mostly retired
 
testpie's Avatar
 
Industry Role:
Join Date: Apr 2006
Location: UK
Posts: 3,231
Quote:
Originally Posted by bigalownz View Post
thanks for your help
will it change the date on all files?
as i just want .html to change
As darksoul said, the script I provided will change all files regardless of extension, and is admittedly exhaustive on CPU and I/O resources because it has to keep opening and closing files. You would be better off taking darksoul's advice and doing the following:
Quote:
Originally Posted by darksoul View Post
go to the directory where the files are and run this command (ssh)
Code:
find . -name "*.html" -print0|xargs -0 touch

P.S. the php script above changes all files regardless of extension
As for me, one day I'll lock myself in a room and force myself to learn the ins and outs of Linux... one day...
__________________

Affiliates: DogFart ~ Domain parking: NameDrive ~ Traffic broker: Traffic Holder
testpie is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-07-2008, 12:55 AM   #10
bigalownz
Confirmed User
 
bigalownz's Avatar
 
Industry Role:
Join Date: Aug 2005
Location: NEW ZEALAND
Posts: 1,657
thanks guys for the help

i used

find . -name "*.html" -print0|xargs -0 touch

and it worked great
__________________
$100 free credit for all hosting needs
bigalownz is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-07-2008, 12:56 AM   #11
bigalownz
Confirmed User
 
bigalownz's Avatar
 
Industry Role:
Join Date: Aug 2005
Location: NEW ZEALAND
Posts: 1,657
Quote:
Originally Posted by testpie View Post

As for me, one day I'll lock myself in a room and force myself to learn the ins and outs of Linux... one day...
i should


it took me years to learn windows
__________________
$100 free credit for all hosting needs
bigalownz is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.