diff options
Diffstat (limited to 'zarb-ml/mageia-discuss/2013-January/009034.html')
-rw-r--r-- | zarb-ml/mageia-discuss/2013-January/009034.html | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/zarb-ml/mageia-discuss/2013-January/009034.html b/zarb-ml/mageia-discuss/2013-January/009034.html new file mode 100644 index 000000000..d80e15f34 --- /dev/null +++ b/zarb-ml/mageia-discuss/2013-January/009034.html @@ -0,0 +1,125 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> +<HTML> + <HEAD> + <TITLE> [Mageia-discuss] Debian-style «rename» utility? + </TITLE> + <LINK REL="Index" HREF="index.html" > + <LINK REL="made" HREF="mailto:mageia-discuss%40mageia.org?Subject=Re%3A%20%5BMageia-discuss%5D%0A%20%3D%3Fiso-8859-15%3Fq%3FDebian-style_%3DABrename%3DBB_utilit%3F%3D%0A%20%3D%3Fiso-8859-15%3Fq%3Fy%3D3F%3F%3D&In-Reply-To=%3C201301012113.02397.renaud%40olgiati-in-paraguay.org%3E"> + <META NAME="robots" CONTENT="index,nofollow"> + <META http-equiv="Content-Type" content="text/html; charset=us-ascii"> + <LINK REL="Previous" HREF="009033.html"> + <LINK REL="Next" HREF="009035.html"> + </HEAD> + <BODY BGCOLOR="#ffffff"> + <H1>[Mageia-discuss] Debian-style «rename» utility?</H1> + <B>Renaud (Ron) Olgiati</B> + <A HREF="mailto:mageia-discuss%40mageia.org?Subject=Re%3A%20%5BMageia-discuss%5D%0A%20%3D%3Fiso-8859-15%3Fq%3FDebian-style_%3DABrename%3DBB_utilit%3F%3D%0A%20%3D%3Fiso-8859-15%3Fq%3Fy%3D3F%3F%3D&In-Reply-To=%3C201301012113.02397.renaud%40olgiati-in-paraguay.org%3E" + TITLE="[Mageia-discuss] Debian-style «rename» utility?">renaud at olgiati-in-paraguay.org + </A><BR> + <I>Wed Jan 2 01:13:02 CET 2013</I> + <P><UL> + <LI>Previous message: <A HREF="009033.html">[Mageia-discuss] Debian-style «rename» utility? +</A></li> + <LI>Next message: <A HREF="009035.html">[Mageia-discuss] Debian-style «rename» utility? +</A></li> + <LI> <B>Messages sorted by:</B> + <a href="date.html#9034">[ date ]</a> + <a href="thread.html#9034">[ thread ]</a> + <a href="subject.html#9034">[ subject ]</a> + <a href="author.html#9034">[ author ]</a> + </LI> + </UL> + <HR> +<!--beginarticle--> +<PRE>On Tuesday 01 Jan 2013 17:58 my mailbox was graced by a message from Johnny A. +Solbu who wrote: +><i> Sometimes I need to mass rename filenames, to replace norwegian special +</I>><i> caracters, to make things work across samba. On Debian th rename utility +</I>><i> user «sed» style replacements, which means one command can replace all +</I>><i> instances of a character or string recursively in all subfolders. But on +</I>><i> Mandriva and Mageia, I have to run the exact same command multiple times +</I>><i> in the same folder to do the same thing. And I can't do it recursively. +</I>><i> +</I>><i> One example. Say I want to recursively replace all spaces ' ' with an +</I>><i> underscore '_' on all files in every subfolder under «folder2» +</I>><i> +</I>><i> On Debian: +</I>><i> replace 's/\ /_/g' folder2/ +</I>><i> +</I>><i> On Mageia: +</I>><i> cd folder2 +</I>><i> replace ' ' '_' * +</I>><i> replace ' ' '_' * +</I>><i> replace ' ' '_' * +</I>><i> replace ' ' '_' * +</I>><i> +</I>><i> cd subfolder1 +</I>><i> replace ' ' '_' * +</I>><i> <repeating> +</I>><i> <repeating> +</I>><i> ...... +</I>><i> and so on. +</I>><i> +</I>><i> Is there a command line utility on Mageia that can do this te way Debian +</I>><i> does this, without resorting to creating a shellscript each time I need to +</I>><i> replace something? (I'm no good at scripting, so I've had to do this +</I>><i> manually for some 11 years.) +</I> +I have been removing spaces and a number of characters that cause problems in +filenames with the following: + +#!/bin/bash +ls | grep " " >totototo +while [ -s totototo ] +do +rename " " _ *" "* +ls | grep " " >totototo +done +for CHR in "(" ")" "," "%" "'" ":" ";" "__" "_-" +do +ls | grep $CHR >totototo +while [ -s totototo ] +do +rename $CHR "" *$CHR* +ls | grep $CHR >totototo +done +rm -f totototo +done +echo "Finished !" + +Forgot why the space character is treated apart from the others, but ISTR that +the for would not work if $CHR was a space. + +Cheers, + +Ron. +-- + The ability to speak several languages is an admirable asset, + but to be able to hold your tongue in one language is absolutely priceless. + + -- <A HREF="http://www.olgiati-in-paraguay.org">http://www.olgiati-in-paraguay.org</A> -- + + +</PRE> + + +<!--endarticle--> + <HR> + <P><UL> + <!--threads--> + <LI>Previous message: <A HREF="009033.html">[Mageia-discuss] Debian-style «rename» utility? +</A></li> + <LI>Next message: <A HREF="009035.html">[Mageia-discuss] Debian-style «rename» utility? +</A></li> + <LI> <B>Messages sorted by:</B> + <a href="date.html#9034">[ date ]</a> + <a href="thread.html#9034">[ thread ]</a> + <a href="subject.html#9034">[ subject ]</a> + <a href="author.html#9034">[ author ]</a> + </LI> + </UL> + +<hr> +<a href="https://www.mageia.org/mailman/listinfo/mageia-discuss">More information about the Mageia-discuss +mailing list</a><br> +</body></html> |