comparing file sizes from files in a directory #2
comparing file sizes from files in a directory
I need some help with this function I was trying to make but came up
futile in. Basically I have this folder called 'original' and another
one called 'new'. In these folders there are .NIF files. Both folders
have the same subdirectory folder and file structure. So if there is
an "original/black/dot.nif" then there will be a "new/black/dot.nif".
The only difference between the two dot.nif files are that they may
not be the same file size. I'm trying to create a function that will
compare the dot.nif from the original folder with the dot.nif from the
new folder and delete the larger dot.nif (thus keeping the smaller one
wherever it may be). I would really appreciate some help.
Basically I tried listing the files into an array for each of the two
top folders (original and new) while trying to exclude subfolders. And
then I was going to run it through a loop to determine which of the
two files from the two arrays were larger/smaller.
> comparing file sizes from files in a directory
> Hello all!
> I need some help with this function I was trying to make but came up
> futile in. Basically I have this folder called 'original' and another
> one called 'new'. In these folders there are .NIF files. Both folders
> have the same subdirectory folder and file structure. So if there is
> an "original/black/dot.nif" the...compare file size with online file size
Im trying to make something that compares 2 files. One of the files is
on the users computer....
The other is on a website!
Obviously what Im trying to do is compare the lastModified date, in
order to update the file on the users computer if neccessary.
Only problem is that I dont know how I can get the size of the file
online without downloading it first...
Would the HTTP "Content-length" header line help you? Some servers
don't send that so sometime you wouldn't know ahead of time. But in
general you can use the urllib module and then the info() metho...files, directories, files, directories
I've been trying to make a decision and it's driving me crazy.
Is a directory a file or is a directory NOT a file but a node?
Should I have
public interface IFile
public interface IDirectory
public interface INode
public interface IFile
public interface IDirectory
Method A is nice cause IFile becomes the base "Node" type and you can use
names like "IFileName" which sounds nice compared to "INodeName" and fits
with the "FileSystem" moniker. A has the disadvantage that IDirectory has a
GetContent() method which isn't bad but can be considered a bit weird. It
probably wouldn't be too hard to make users think of everything as a file.
Method B is nice cause IDirectory doesn't have GetContent() -- that honour
belongs only to IFile. B is at a disadvantage when it comes to naming:
everything becomes a "Node". INodeName sounds rude compared to IFileName.
This method feels more "pure" cause you're specialising features completely.
Do you reckon I can get away with Method A? It doesn't seem as pure unless
you spend a long time convincing yourself that (for all intents and
purposes) a file *is* a node (it's just got a different name) and a
directory *is* a file.
A penny for anyone's thought...tar file with . files and . directories
i want to create a tar file with all my . files and . directories in
my home directory.
i cannot create a tar file without having all my files in it
is there a way to create such a tar file?
thanx in advance
On Tue, 02 Mar 2004 23:00:47 +0000, Hannes wrote:
> i want to create a tar file with all my . files and . directories in my
> home directory.
> i cannot create a tar file without having all my files in it is there a
> way to create such a tar file?
Not very clear what you want to do. If you don't want some files to be
archived, use...How to tar.gz a directory tree WITHOUT files greater than 30 MB file size?
How can I *.tar.gz a whole directory tree (say \home\myname\) but all files inside which are
greater than 30 MB should not be included ?
Matt Stevens wrote:
> How can I *.tar.gz a whole directory tree (say \home\myname\) but all files inside which are
> greater than 30 MB should not be included ?
Use "find -size" to generate a list of files less than a specific size.
"man find" for more info.
Then use "tar -T" to tar the files.
"man tar" for more info.
You might even be able to pipe them together (- for -T), although I've
never tried....Solution to synchronize 300,000 files over FTP without file by file comparing?
Need help to effectively synchronize 3 machines (XP pro, 2000 pro and
98SE) with 3 different FTP Servers (Titan, Raiden and Serv U)
Each machines has about 15 Gigabytes in total of 300,000 15k to 900k
TIFF files spanning 15 levels of 6000 folders. Servers are connected
by broadband, upload transfer rate is 640K on 2 Servers and 4000K on 1
100 to 200 new files are added in each server daily and not much files
are modified (10 to 30 in total maybe)
We are using WS_ftp synchronize utility performing Server A to B sync
(3 hours) then A to C sync (3 hours) and A to B again (3 hours) to make
the files identical. That is a full day job. And most of the time is
scanning and comparing files.
We can't schedule the job because the synchronization halt from time to
time. We need to reboot the FTP server or the client and start the
task again. I doubt it is caused by the large number of files with
small size, we tried to synchronize 4 DVD movies between 3 servers and
the whole process finished in half the time needed and never halt.
Recently the synchronization is getting slower and those non technical
staffs (those who created 6000 folders) are complaining.
I have tried Availl replicate from Availl.com, but it doesn't seem to
operate well for such a large number of files.
tried Syncback from 2brightsparks, replicate locally is great, but
across ftp doesn't get the job done.
tried remote control each server and backup newly added files but the...file extention from file file location
I am new to perl (only working on this one problem) but I program in other
We have an upload script written in cgi. Can anyone tell me how to get the
file extension from the variable $File1 (actual file location on uploader's
computer) then find out if it is equal to "txt"
Thanks in advance for not telling me to read the manual.
PLEASE NOTE: comp.infosystems.www.authoring.cgi is a
SELF-MODERATED newsgroup. aa.net and boutell.com are
NOT the originators of the articles and are NOT responsible
for their content.
HOW TO POST to co...File size vs. Directory size problem
Got a bit of a problem I dont know how to go about.
Basically my script takes 2 different directories, puts each file/sub
directory into an array for each, sorts the array, compares them, and
then spits out what is missing from each directory. Im really happy with
this as it is my first real ruby script and it works a charm.
Now I was wanting to add to it. Basically I want to take the size of
each file and see if they are greater than 0, and if it is 0 then output
My problem is that a directory is returned as being of size 0. Obviously
I dont care about the directory size i...workspace file size v.s. stored JPEG file size
I'm having some difficulty understanding why there is a difference in file size between an image in my workspace, the same image when I write it as a JPEG using imwrite(), and the re-read image back into my workspace. I know JPEG can be used a lossy format, which makes sense why the file size would be less, but my question is less about the whole lossy/lossless mode discrepancy and more about why I get two different values for the same file.
Let me illustrate this with a brief example:
%Make a 128x128 "image" - 16384 bytes
img = uint8(randi(128,128));
%Write the...Is a PHP variable supposed to be seen in a .js file included into a .php file
Is a PHP variable supposed to be seen in a .js file included into a .php
into a PHP file using
The string is supposed to be the value of $HTTP_HOST
So, when initialise this variable like
var u=<? echo $HTTP_HOST;?>;
Am I doing something wrong, or PHP variables are not seen in included js
> Is a PHP variable supposed to be seen in a .js file included into a .php
> into a PHP file using
> <script src="filename.js></script>
> var u="string";
> The string is supposed to be the value of $HTTP_HOST
> So, when initialise this variable like
> var u=<? echo $HTTP_HOST;?>;
> Am I doing something wrong, or PHP variables are not seen in included js
js files are not parsed for PHP code unless you specifically tell the
webserver to do so. Therefore, "var u=<? echo $HTTP_HOST;?>;" in the .js
will error since the browser doesn't know what to do.
Justin Koivisto - spam@koiv...want to get content of one php file in another php file
i have one php file having content
Contents of ex1.php file
$content = "c://webserver/www/abc.php";
$handle = fopen($content, "r");
this is reading abc.php file in which i m simply using an echo
statement. When i execute ex1.php file i cant see the php statement of
content of abc.php file is
<?php echo "hello";?>
> i have one php file having content
> Contents of ex1.php file
> $content = "c://webserver/www/abc.php";
> $handle = fopen($content, "r");
> echo fread($handle,filesize($content));
> this is reading abc.php file in which i m simply using an echo
> statement. When i execute ex1.php file i cant see the php statement of
> abc.php file
> content of abc.php file is
> <?php echo "hello";?>
That's interesting, I've found out that it's the browser that's hiding <?php
?> tags within .phpx pages. Probably to avoid short tags scripts (on a
server that doesn't allow them) from getting leaked by visitors who don't
know about this browser trick, until the dev' realizes his error.
Not a good thing, IMO; dev's should take care, themselves, and it's still
not secure since the hidden string is still in the rendered source. And now
we don't know how ...Open .php file with PHP Designer 2007 by clicking the file in XP
In windows XP, I want to be able to click on a .php file and have it
opened in PHP Designer 2007,
Or right-click on it and have an "edit" menu option presented to me.
I know how to tweak the registry to do this in general, but what would
the command line look like in this specific case ?
PHP Designer does not do this automatically. It is as if the program
does not allow commandline options.
It only opens with the last file used or a menu of recently opened
...Iteration through File.file? misses entries for which File.file?(entry) == true
I'm new to Ruby, so I'm most likely making an elementary mistake.
However, searching Google didn't help me find my answer, and after
mucking around with irb I still haven't figured it out.
I wrote a method that was intended to take all of the files in a given
directory and put them into an array. Here's the code I wrote:
pwdFiles = Array.new
Dir.foreach(dir) do |entry|
pwdFiles.push(entry) if File.file?(entry) == true
This works fine when called on the working directory --- that is,
getFile...file php how a js recalled by other file
I have a File0.php with code:
<?php $var2='Hello'; ?>
var vp2 = '<?php print $var2; ?>' ;
but would like to use other solutions, also to see how work php with js:
1) var vp2 = '<?php $var2; ?>' ;
why so not work ? (absolute want print or echo)
2) to move this row <?php $var2='Hello'; ?>
form File0.php to a new file1.js
see that it is a php code, think that only solution is however to make a
File0.php: is possible , how ?
(noice, not want use include o require beause interesting at insert .js (or
simulation) inner php file)
...Getting file size of binary file
Is using fseek and ftell a reliable method of getting the file size on a
binary file? I thought I remember reading somewhere it wasn't... If not what
would be the "right" and portable method to obtain it? Thanks.
"Arnold" <email@example.com> wrote:
> Is using fseek and ftell a reliable method of getting the file size on a
> binary file?
No. From 22.214.171.124#3: "A binary stream need not meaningfully support
fseek calls with a whence value of SEEK_END".
To say that this irks me would be a bit of an understatement.
> I thought I remember read...Comparing files in a zip to files on drive
I am attempting to incrementally back up files using python. How can I
compare a file on a hard drive to a file in a python created zip file
to tell if the file has changed? Or should I be using some other
method to determine if a file has changed?
> compare a file on a hard drive to a file in a python created zip file
> to tell if the file has changed?
>>> fileondisk = r'C:\Documents and Settings\power\Desktop\ES3dc+Template.3f'
>>> zipondisk = r'C:\Documents and Settings\power\Desktop\temps.zip'
>>> import zipfile
>>> z = zipfile.ZipFile(zipondisk)
['ES1+Template.3f', 'ES3sc+Template.3f', 'ES3dc+Template.3f']
>>> info = z.getinfo('ES3dc+Template.3f')
>>> import binascii
>>> checksum = 0
>>> fp = open(fileondisk, 'rb')
>>> while 1:
.... data = fp.read(32*1024)
.... if not data: break
.... checksum = binascii.crc32(data, checksum)
> I am attempting to incrementally back up files using python. How can I
> compare a file on a hard drive to a file in a python created zip file
> to tell if the file has changed? Or should I be using some other
> method to determine if a file has changed?
You can easily determine size and date from the hard drive/filesystem
and from zip file...Testing file size and file exist?
I want to perform a couple of statements if either the file does not exist OR the file size of a given file
is equal 0. Currently the best solution I can imagine is something like:
if [! -e myfile.dat ]; then
echo "File not existing or file size = 0"
filesize=`wc -c myfile.dat`
if [ $filesize = 0 ]; then
echo "File not existing or file size = 0"
The first problem I encounter is that the back ticks are NOT recognized by the shell interpreter.
filesize contains blank af...File.size? incorrect for big files?
I've written a script to monitor some files stored on our network. The
files range from a few hundred MB to 20-50g. Above a certain point
which I haven't really narrowed down yet, the file sizes start being
reported incorrectly from my script. It's as if the routine that does
the system query is using a 32 bit thing for the size and it's getting
truncated as integers do. Some files actually come back with a negative
size. The data type that ruby is using is perfectly capable of holding
the size of the files. I've tried File.size? and FileUtils.size?, so
I'm so...File Permissions of PHP Session Files
I noticed that the file permissions (unix) of the PHP session files
have only read and write permissions for the Apache process (600 or rw-
Does anyone have any idea where this permission is set ? I can't find
umask or chmod settings for it in the php.ini file. Can't find
the httpd.conf either. Is it set in the PHP code that implements
Thanks for any pointers
Those files are created and modified by the the apache process, so you
probably want the umask of that user (most likely "nobody").
Just out of curiosity, why do you...Maximum File Size of memo file
I want to write an application to store word documents into the Memop field.
What is the maximum size of the memo file(fpt File), in CDX, ADS-CDX,
ADS-ADT file format?
Mit freundlichen Gr��en
Kleine Mauerstra�e 1
Tel.: +49(0)5221/911 46-0
Fax: +49(0)5221/911 46-4
J�rgen Knauf schrieb in <firstname.lastname@example.org>:
> What is the maximum size of the memo file(fpt File), in CDX, ADS-CDX,
AFAIK 4 GB
> ADS-ADT f...PHP File upload
I have to allow my visitors to upload image on my site.
I am using the follwoing code to do that:
$uploaddir = 'admin/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
My problem is that I expect them to use same file name, like all of
them will be uploading files like, comments.rtf. So if there is already
one comments.rtf the file will get overwriten... so the challenge is to
rename the files to username-filename.rtf
can anybody here will take the pain to modify...File Upload
I'm writing a script to upload images along with articles to a
directory on the server. I'm developing it offline on my WinXP and
Apache 1.3.x laptop and it's working great, but when I move the script
to the server, I get write errors when the file attempts to upload.
So I set up a test script (included below) to test the directory
structures all the way up to the file, and every directory appears to
be writable, yet I can't write to the test file. I keep seeing
suggestions to set the open_basedir directive in the php.ini file to
solve this, but it's hasn't worked ye...SSI Including PHP File Within PHP File Causes Seg Fault and Crash
Can somebody concur or verify the following? I'm having this problem on all
of my installations.
I've got Apache 2.0.40 and PHP 4.2.2 installed and configured from RedHat
RPMs. Nothing out of the ordinary. In the httpd.conf file, PHP files are
called with the following:
I create two files as follows:
<!--#include virtaul="/test2.php" -->
Testing 1 2 3
By going to http://host/test1.php, it may or may not display the fi...Script to move files with one occurence of a string to one directory, and other files to another directory?
I could use a script for the bash shell to look through a group of files (s=
elected from one directory by a wildcard expression) and move any of those =
files with exactly one occurrence of the string Path: to a different direct=
ory, usually a subdirectory of the first directory. The rest of the files =
selected by the wildcard expression are move to a third directory, also usu=
ally a subdirectory of the first directory. I'm currently doing this manua=
lly, but with grep commands to count the number of occurrences.
NOT homework - I'm retired. Actually using Cygwin (an em...