Penguin
Diff: BashOneLiners
EditPageHistoryDiffInfoLikePages

Differences between current version and revision by previous author of BashOneLiners.

Other diffs: Previous Major Revision, Previous Revision, or view the Annotated Edit History

Newer page: version 26 Last edited on Tuesday, April 1, 2008 11:24:51 am by DanielLawson
Older page: version 24 Last edited on Friday, October 12, 2007 1:17:38 am by AlastairPorter Revert
@@ -100,4 +100,16 @@
  <verbatim> 
  aptitude search ~g | while read ; do echo "$RANDOM $REPLY" ; done | sort -n | head -1 | cut -d' ' -f2- 
  </verbatim> 
  —AristotlePagaltzis 
+  
+----  
+  
+!!! Rename a series of files using a regular expressions  
+  
+There's a number of ways of doing this, all with various problems. I finally settled on the following (Thanks [#wlug], and Isomer and Phil in particular):  
+  
+ <verbatim>  
+ find . -iname '*:*' -exec rename s/:/-/ '{}' ';'  
+ </verbatim>  
+  
+This was needed in particular because the filenames had double spaces in them and trailing spaces, which ultimately defeated my rather rusty attempts at using bash. I'm replacing ':' with '-' because Macs allow you to create a file or a directory with a '/' in the name, but represent this on the filesystem as a ':'. This causes problems over CIFS shares however. -DanielLawson