[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: Sv: [NOVICE] bash-prog



Dette vil gøre det du vil have:

#!/bin/bash
#Opret variabel med en startværdi
X=1
#Kør forløkken i et bestemt dir.
for Y in /path/to/files/*; do
  mv $Y $X
  #Inkremere X med 1
  X=$[ $X + 1 ]
done
#færdig

Håber det hjælper :-)

-- 
Bjarke Bruun - E-mail: sslug@sslug http://linux.hhknet.dk
   __
  / /  (_)__  __ ____  __
 / /__/ / _ \/ // /\ \/ /  . . .  t h e   c h o i c e   o f   a
/____/_/_//_/\_,_/ /_/\_\              G N U   g e n e r a t i o n . . .



Kjeld Vang Larsen wrote:
> 
> Hej Martin!
> 
> Tak fro det. det kan godt være at det hører
> til en anden kat. Men nu ligger den altså her
> ;-)
> Det er jo sikkert et novice-sprøgsmål.
> Den første linie henviser til Perl. Det
> er ikke noget jeg har installeret (tror jeg),
> Men det kan vel laves på en lignende måde
> til bash!????
> 
> Men Ellers tak.
> 
> Kjeld
> 
> Martin <sslug@sslug> skrev i en
> nyhedsmeddelelse:sslug@sslug
> > KVL> Jeg skal bruge et lille script der kan rename en flok filer
> > KVL> med løbende nr. De må gere blive liggende i samme mappe,
> > KVL> men det er ok hvis ikke.
> > KVL> Er der nogen kan hjælpe mig med det??
> >
> > Hej der,
> >
> > Jeg ved ikke om denne slags problemer er passende paa denne liste
> > (tror der er en specific liste for det) - men her er et lille script
> > jeg brugte til at rename alle mine billeder (som laa i et dir der hed
> > "pic") - Jeg har tilfoejet et par kommentarer, saa du forhaabentligt
> > kan tilpasse scriptet til dit behov:
> >
> > ---
> > #!/usr/bin/perl
> >
> > # set directoryname - and go there (clumsy, but it works)
> > $dirname="pic";
> > chdir($dirname);
> > opendir(D, ".");
> > @files=grep(-f, readdir(D));    # get a list of all files (no directories)
> > closedir(D);
> >
> > print "Files are: @files\n";
> > # a little loop, where we keep adding one to the value
> > while($file = shift @files) {
> >    $new_file_num++;
> >    print "Rename $file to "Firmafest_$new_file_num.jpg\n";
> > #   rename $file, "Firmafest_$new_file_num.jpg";    # uncomment this line
> to really rename the files
> > }
> > ---
> >
> > LAeg maerke til at selve scriptet ligger en tak laengere ude end selve
> > filerne, det var den nemmeste lille workaround - da scriptet ellers
> > ville rename sig selv til  Firmafest_67.jpg ;)
> >
> > Held og lykke!
> >
> > Martin
> >
> >


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 19:19 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *