* delete-file using wildcard
@ 2011-10-29 7:54 ishi soichi
2011-10-29 8:12 ` Jambunathan K
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: ishi soichi @ 2011-10-29 7:54 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 391 bytes --]
I have a question about Emacs Lisp, which I believe is simple enough for
most of you.
I would like to delete files in a directory.
When doing so with Linux command, we usually do,
> rm *
at that directory.
the wildcard command does not seem work similarly in Emacs Lisp.
(delete-file (subseq (file-expand-wildcards "~/Desktop/*") -1))
doesn't work.
Could anyone help me out?
soichi
[-- Attachment #2: Type: text/html, Size: 629 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: delete-file using wildcard
2011-10-29 7:54 delete-file using wildcard ishi soichi
@ 2011-10-29 8:12 ` Jambunathan K
2011-10-29 8:48 ` Tassilo Horn
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: Jambunathan K @ 2011-10-29 8:12 UTC (permalink / raw)
To: ishi soichi; +Cc: help-gnu-emacs
May be you should use dired.
1. C-x C-f ~/tmp RET
2. * % \.pdf$
3. t
4. k
5. t
6. D
1 => visit directory in dired
2 => mark all pdf files. Uses emacs style regexps
3 => toggle mark. this marks all non-pdf files
4 => kill mark. Removes the display of files marked in 3
5 => toggle mark. this marks all pdf files. This shows (just) the files that you
will be operating upon
6 => Delete the chosen files
Steps 3,4 and 5 are optional.
Use with caution.
> I have a question about Emacs Lisp, which I believe is simple enough
> for most of you.
>
>
> I would like to delete files in a directory.
> When doing so with Linux command, we usually do,
>
>> rm *
>
> at that directory.
>
> the wildcard command does not seem work similarly in Emacs Lisp.
>
> (delete-file (subseq (file-expand-wildcards "~/Desktop/*") -1))
>
> doesn't work.
>
> Could anyone help me out?
>
> soichi
>
>
--
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: delete-file using wildcard
2011-10-29 7:54 delete-file using wildcard ishi soichi
2011-10-29 8:12 ` Jambunathan K
@ 2011-10-29 8:48 ` Tassilo Horn
2011-10-29 8:50 ` Tassilo Horn
2011-10-29 8:57 ` ishi soichi
2011-10-29 9:03 ` Peter Dyballa
2011-10-29 14:16 ` Drew Adams
3 siblings, 2 replies; 8+ messages in thread
From: Tassilo Horn @ 2011-10-29 8:48 UTC (permalink / raw)
To: help-gnu-emacs
ishi soichi <soichi777@gmail.com> writes:
Hi!
> the wildcard command does not seem work similarly in Emacs Lisp.
>
> (delete-file (subseq (file-expand-wildcards "~/Desktop/*") -1))
`delete-file' wants exactly one file given as string, but the `subseq'
form returns a *list* with exactly one file name, i.e., the last file
matching the given wildcard.
This should do the trick:
(delete-file (nth 0 (subseq (file-expand-wildcards "~/Desktop/*") -1)))
Bye,
Tassilo
--
(What the world needs (I think) is not
(a Lisp (with fewer parentheses))
but (an English (with more.)))
Brian Hayes, http://tinyurl.com/3y9l2kf
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: delete-file using wildcard
2011-10-29 8:48 ` Tassilo Horn
@ 2011-10-29 8:50 ` Tassilo Horn
2011-10-29 8:57 ` ishi soichi
1 sibling, 0 replies; 8+ messages in thread
From: Tassilo Horn @ 2011-10-29 8:50 UTC (permalink / raw)
To: help-gnu-emacs
Tassilo Horn <tassilo@member.fsf.org> writes:
> ishi soichi <soichi777@gmail.com> writes:
>
> Hi!
>
>> the wildcard command does not seem work similarly in Emacs Lisp.
>>
>> (delete-file (subseq (file-expand-wildcards "~/Desktop/*") -1))
>
> `delete-file' wants exactly one file given as string, but the `subseq'
> form returns a *list* with exactly one file name, i.e., the last file
> matching the given wildcard.
>
> This should do the trick:
>
> (delete-file (nth 0 (subseq (file-expand-wildcards "~/Desktop/*") -1)))
Argh, of course one would use `car' instead of `nth' here.
Bye,
Tassilo
--
(What the world needs (I think) is not
(a Lisp (with fewer parentheses))
but (an English (with more.)))
Brian Hayes, http://tinyurl.com/3y9l2kf
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: delete-file using wildcard
2011-10-29 8:48 ` Tassilo Horn
2011-10-29 8:50 ` Tassilo Horn
@ 2011-10-29 8:57 ` ishi soichi
1 sibling, 0 replies; 8+ messages in thread
From: ishi soichi @ 2011-10-29 8:57 UTC (permalink / raw)
To: Tassilo Horn; +Cc: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 750 bytes --]
Thanks! It helped.
soichi
2011/10/29 Tassilo Horn <tassilo@member.fsf.org>
> ishi soichi <soichi777@gmail.com> writes:
>
> Hi!
>
> > the wildcard command does not seem work similarly in Emacs Lisp.
> >
> > (delete-file (subseq (file-expand-wildcards "~/Desktop/*") -1))
>
> `delete-file' wants exactly one file given as string, but the `subseq'
> form returns a *list* with exactly one file name, i.e., the last file
> matching the given wildcard.
>
> This should do the trick:
>
> (delete-file (nth 0 (subseq (file-expand-wildcards "~/Desktop/*") -1)))
>
> Bye,
> Tassilo
> --
> (What the world needs (I think) is not
> (a Lisp (with fewer parentheses))
> but (an English (with more.)))
> Brian Hayes, http://tinyurl.com/3y9l2kf
>
>
>
[-- Attachment #2: Type: text/html, Size: 1297 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: delete-file using wildcard
2011-10-29 7:54 delete-file using wildcard ishi soichi
2011-10-29 8:12 ` Jambunathan K
2011-10-29 8:48 ` Tassilo Horn
@ 2011-10-29 9:03 ` Peter Dyballa
2011-10-29 14:16 ` Drew Adams
3 siblings, 0 replies; 8+ messages in thread
From: Peter Dyballa @ 2011-10-29 9:03 UTC (permalink / raw)
To: ishi soichi; +Cc: help-gnu-emacs
Am 29.10.2011 um 09:54 schrieb ishi soichi:
> I would like to delete files in a directory.
> When doing so with Linux command, we usually do,
>
>> rm *
>
> at that directory.
You could use a shell-command that performs exactly this.
--
Greetings
<]
Pete o __o |__ o recumbo
___o /I -\<, |o \ -\),-% ergo sum!
___/\ /\___./ \___...O/ O____.....`-O-'-()--o_________________
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: delete-file using wildcard
2011-10-29 7:54 delete-file using wildcard ishi soichi
` (2 preceding siblings ...)
2011-10-29 9:03 ` Peter Dyballa
@ 2011-10-29 14:16 ` Drew Adams
2011-10-29 20:30 ` ishi soichi
3 siblings, 1 reply; 8+ messages in thread
From: Drew Adams @ 2011-10-29 14:16 UTC (permalink / raw)
To: 'ishi soichi', help-gnu-emacs
> I would like to delete files in a directory.
> When doing so with Linux command, we usually do, rm *
> at that directory.
> the wildcard command does not seem work similarly in Emacs Lisp.
> (delete-file (subseq (file-expand-wildcards "~/Desktop/*") -1))
> doesn't work. Could anyone help me out?
Others have provided some solutions. To do it interactively, Dired is your
friend, as Jambunathan suggested.
Another interactive solution is `icicle-delete-file'. It's a multi-command
version of `delete-file', which means that you can act on (delete, in this case)
any number of files and directories with the same command invocation.
For your example, just do this: M-x icicle-delete-file TAB C-!
You can type a pattern to match, before hitting TAB (or S-TAB, if the pattern is
a regexp). The key `C-!' means act on *all* matching candidates. Whatever file
names currently match your minibuffer input (they are shown in *Completions*),
those files are deleted. Or use `C-mouse-2' or `C-RET' to act on only one
candidate at a time.
Change your input (pattern) to act on different files. You can also change to
another directory, using `C-c C-d'. All during the same command invocation.
Use C-g to end the command (or RET to act on one final candidate).
http://www.emacswiki.org/emacs/Icicles_-_Multi-Commands#toc3
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: delete-file using wildcard
2011-10-29 14:16 ` Drew Adams
@ 2011-10-29 20:30 ` ishi soichi
0 siblings, 0 replies; 8+ messages in thread
From: ishi soichi @ 2011-10-29 20:30 UTC (permalink / raw)
To: Drew Adams; +Cc: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1491 bytes --]
Thanks for many solutions.
I appreciate it!
soichi
2011/10/29 Drew Adams <drew.adams@oracle.com>
> > I would like to delete files in a directory.
> > When doing so with Linux command, we usually do, rm *
> > at that directory.
> > the wildcard command does not seem work similarly in Emacs Lisp.
> > (delete-file (subseq (file-expand-wildcards "~/Desktop/*") -1))
> > doesn't work. Could anyone help me out?
>
> Others have provided some solutions. To do it interactively, Dired is your
> friend, as Jambunathan suggested.
>
> Another interactive solution is `icicle-delete-file'. It's a multi-command
> version of `delete-file', which means that you can act on (delete, in this
> case)
> any number of files and directories with the same command invocation.
>
> For your example, just do this: M-x icicle-delete-file TAB C-!
>
> You can type a pattern to match, before hitting TAB (or S-TAB, if the
> pattern is
> a regexp). The key `C-!' means act on *all* matching candidates.
> Whatever file
> names currently match your minibuffer input (they are shown in
> *Completions*),
> those files are deleted. Or use `C-mouse-2' or `C-RET' to act on only one
> candidate at a time.
>
> Change your input (pattern) to act on different files. You can also
> change to
> another directory, using `C-c C-d'. All during the same command
> invocation.
> Use C-g to end the command (or RET to act on one final candidate).
>
> http://www.emacswiki.org/emacs/Icicles_-_Multi-Commands#toc3
>
>
[-- Attachment #2: Type: text/html, Size: 2010 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2011-10-29 20:30 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-29 7:54 delete-file using wildcard ishi soichi
2011-10-29 8:12 ` Jambunathan K
2011-10-29 8:48 ` Tassilo Horn
2011-10-29 8:50 ` Tassilo Horn
2011-10-29 8:57 ` ishi soichi
2011-10-29 9:03 ` Peter Dyballa
2011-10-29 14:16 ` Drew Adams
2011-10-29 20:30 ` ishi soichi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).