
ironpaw
Novice
Feb 4, 2003, 7:07 PM
Post #6 of 12
(2504 views)
|
Re: [ironpaw] setting timestamps on files utime or alternatives
[In reply to]
|
Can't Post
|
|
The problem is that utime does not set dates for files you do not own (even if you have write access). The answer in my case was to run the script on the unix box as root who owns all files. Unix does not like spaces in files so the script got modified. Utime does not work with: utime ($variablefordate, $variablefordate ,"$FullPathAndFileName"); but does work with (keep in mind these file names and paths contain spaces) utime ($variablefordate, $variablefordate ,"$JustFileName"); # this works if your already in the correct directory.. chdir("/path/with spaces/ok); Here is my final script #!/usr/bin/perl -w open(CSV, "/tmp/doctime.txt"); @title = <CSV>; for ($i = 0; $i < scalar(@title); $i++) { ($dironly[$i], $filename[$i], $date[$i]) = split(",", $title[$i]); } for ($a = 0; $a < scalar(@filename); $a++) { $access= $date[$a]; $file = $filename[$a]; $dir = $dironly[$a]; chdir("$dir"); print "$dir $file $access\n"; print utime ($access, $access, "$file"), "\n"; print "\n\n"; } ############### All Life is Kaos ###############
|