Re: adding leading zeros to a filename
From: Stephane CHAZELAS (this.address_at_is.invalid)
Date: 01/31/05
- Next message: Christophe Delarue: "sh -c "tcsh -c ls""
- Previous message: Stephane CHAZELAS: "Re: while [...] && [...] this doesn't work"
- In reply to: Chris F.A. Johnson: "Re: adding leading zeros to a filename"
- Next in thread: Stephane CHAZELAS: "Re: adding leading zeros to a filename"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 31 Jan 2005 09:25:45 +0000
2005-01-30, 22:15(+00), Chris F.A. Johnson:
[...]
> You can test before the loop:
>
> set -- *.jpg
> [ -f "$1" ] &&
> for file
> do
> : do whatever with "$file"
> done
[...]
what if:
mkdir 1.jpg
touch 2.jpg
?
> Or you can test within the loop:
>
> for file in *.jpg
> do
> [ -f "$file" ] || continue
> : do whatever with "$file"
> done
[...]
Better (as long as you require the files to be regular files or
symlinks to regular files which is likely to be the case for jpg
files).
-- Stéphane
- Next message: Christophe Delarue: "sh -c "tcsh -c ls""
- Previous message: Stephane CHAZELAS: "Re: while [...] && [...] this doesn't work"
- In reply to: Chris F.A. Johnson: "Re: adding leading zeros to a filename"
- Next in thread: Stephane CHAZELAS: "Re: adding leading zeros to a filename"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|