Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Organising photos into a list (O/T)



Peter Stephenson <pws@xxxxxxx> wrote in news:200703091237.l29CbP80026608
@news01.csr.com:

> Bart Schaefer wrote:
>> On Mar 9, 10:15am, zzapper wrote:
>> }
>> } I needed to organise about 60 images into a numerical list.
>> [...]
>> } (Just realised, the best way would have been to print them all and 
then 
>> } organise them on a table: but that would have taken ages)
>> 
>> If the file names or dates don't already reflect something close to the
>> ordering you want, so you have to look at the pictures to number them,


> # Get the list of files as currently ordered
> array1=(*)
> # Output one per line to a file
> print -l $array1 >file
> # Edit the file.  Just reorder the lines the way you want.
> vi file
> # Put the ordered files into a new array
> array2=(${(f)"$(<file)"})
> # Sanity check
> (( ${#array1} != ${#array2} )) && print 'Wrong number of files!'
> # Rename files into a subdirectory, which
> # prevents overwriting.  (This is paranoia if
> # your are adding numbers.)
> mkdir newnames
> # Use 3 digit numbers (arbitrary).
> integer -Z 3 i
> typeset name
> # For each file in the required order...
> for (( i = 1; i <= ${#array2}; i++ )); do
>    name=$array2[i]
>    # Move into the subdirectory tagged with the new position as index.
>    mv $name newnames/${i}_$name
> done
> 
Peter,
Yes that's the way to do it!
Now why couldn't you have told me this yesterday <G>!!!









Messages sorted by: Reverse Date, Date, Thread, Author