[TriLUG] cp errror "Argument list too long"

William Sutton william at trilug.org
Tue Jul 26 13:00:49 EDT 2005


it shouldn't....because it's ls'ing a directory not a bunch of files.  you 
can try this for yourself...

ls -1rt /path/to/your/full/directory

and should promptly see every file there scroll by.  If you decide to use 
the code, note the unlink() call.  Take it out if you want to keep the 
original files....or adapt the code to your purpose...this should be a 
decent start at what you want to do :)

-- 
William Sutton

On Tue, 26 Jul 2005, Greg Brown wrote:

> Yeah, but wouldn't the ls called in your perl script still crap out
> because of too many aruguments (files in the directory)?
> 
> Greg
> 
> On 7/26/05, William Sutton <william at trilug.org> wrote:
> > It's not entirely hopeless...I tried the following and it appears to
> > work...
> > 
> > I created 4 .jpg files named 1.jpg through 4.jpg, containing the
> > equivalent number.  I then executed the following commands in sequence:
> > 
> > touch num.mpeg
> > convert -delay 0 num.mpeg 1.jpg num.mpeg
> > convert -delay 0 num.mpeg 2.jpg num.mpeg
> > convert -delay 0 num.mpeg 3.jpg num.mpeg
> > convert -delay 0 num.mpeg 4.jpg num.mpeg
> > convert -delay 0 num.mpeg 1.jpg num.mpeg
> > convert -delay 0 num.mpeg 2.jpg num.mpeg
> > convert -delay 0 num.mpeg 3.jpg num.mpeg
> > convert -delay 0 num.mpeg 4.jpg num.mpeg
> > convert -delay 20 num.mpeg num.mpeg
> > 
> > You can see the files at http://trilug.org/~william/convert
> > 
> > basically I think this can be made to work as I indicated below...see
> > revised code:
> > 
> > #!/usr/bin/perl
> > #-----
> > use strict;
> > 
> > my $convert = `which convert`;
> > chomp($convert);
> > 
> > # change to suit your needs
> > my $input_dir = "/home/william/convert";
> > my $output_dir = "/home/william/public_html/convert";
> > my $frame_delay = 20;
> > 
> > my $output_file = "output.mpeg";
> > my @input_files = map { chomp($_); $_; } `/bin/ls $input_dir`;
> > 
> > foreach my $file (@input_files)
> > {
> >     `mv $input_dir/$file $output_dir`;
> >     `$convert -delay 0 $output_dir/$output_file $output_dir/$file \
> >         $output_dir/$output_file`;
> >     unlink("$output_dir/$file");
> > }
> > 
> > `$convert -delay $frame_delay $output_dir/$output_file \
> >     $output_dir/$output_file`;
> > 
> > #-----
> > 
> > to join multiple mpeg files, I think you should be able to do the
> > following:
> > 
> > convert -delay 0 *.mpeg out.mpeg
> > 
> > HTH!
> > 
> > William Sutton
> > 
> > On Mon, 25 Jul 2005, Michael Tharp wrote:
> > 
> > > William Sutton wrote:
> > >
> > > >Maybe it's time to switch to Perl :)
> > > >
> > > >#-----
> > > >my @file = map { chomp($_); $_; } `ls -1rt /path/to/files`;
> > > >
> > > >foreach my $file (@files)
> > > >{
> > > >    next unless -f "/path/to/files/$file";
> > > >
> > > >    `cp /path/to/file/$file /tmp/date`;
> > > >    # your convert code here
> > > >    # and, if you want, uncomment the next line
> > > >    # unlink ("/path/to/files/$file");
> > > >}
> > > >
> > > >
> > > The problem here is that he's not converting multiple
> > > files ito multiple files, but rather multiple files into one
> > > file, so I'm not sure this approach will help any. Perhaps
> > > convert batches of as many files as will fit in one command
> > > line, then seam the files together?
> > >
> > > Michael Tharp
> > >
> > --
> > TriLUG mailing list        : http://www.trilug.org/mailman/listinfo/trilug
> > TriLUG Organizational FAQ  : http://trilug.org/faq/
> > TriLUG Member Services FAQ : http://members.trilug.org/services_faq/
> > TriLUG PGP Keyring         : http://trilug.org/~chrish/trilug.asc
> >
> --
> TriLUG mailing list        : http://www.trilug.org/mailman/listinfo/trilug
> TriLUG Organizational FAQ  : http://trilug.org/faq/
> TriLUG Member Services FAQ : http://members.trilug.org/services_faq/
> TriLUG PGP Keyring         : http://trilug.org/~chrish/trilug.asc
> 
> 



More information about the TriLUG mailing list