Re: remove double quote character from file names
- Reply: Steve O'Hara-Smith : "Re: remove double quote character from file names"
- Reply: Arthur Chance : "Re: remove double quote character from file names"
- Reply: Sysadmin Lists : "Re: remove double quote character from file names"
- In reply to: Sysadmin Lists : "Re: remove double quote character from file names"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 16 Feb 2023 10:24:31 UTC
On Thu, 16 Feb 2023 08:20:09 +0100 (CET), Sysadmin Lists wrote:
> [...]
> Just to throw in an awk-themed solution:
> $ ls -1 | awk '/"/ { system("mv -v '\''" $0 "'\'' " $0) }'
>
> $ touch "\"foo bar\"" \"baz\" \".zap\" xyz abc
> $ ls -1A
> ".zap"
> "baz"
> "foo bar"
> abc
> xyz
> $ ls -1 | awk '/"/ { system("mv -v '\''" $0 "'\'' " $0) }'
> ".zap" -> .zap
> "baz" -> baz
> "foo bar" -> foo bar
> $ ls -1A
> .zap
> abc
> baz
> foo bar
> xyz
>
> There's a clever use of the existing double-quotes in the filenames
> in the renaming.
This is actually a quite clever "ab"use of existing quotes.
Just a friendly sidenote:
Never expect anything. It _might_ be possible that filenames
such as
foo "bar" blah.txt
"meow" 123.dat
doodle "boo" .c++
-my brain hurts ."tar".gz
exist in the heap of files to be processed. Selecting a good
delimiter for input files is hard. Using the "IFS = \n" approach
works - as long as there are no newlines in filenames (which
I'm not sure could also be allowed)... ;-)
--
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...