From owner-freebsd-questions@FreeBSD.ORG Thu May 18 10:40:09 2006 Return-Path: X-Original-To: questions@freebsd.org Delivered-To: freebsd-questions@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 53F6316A407 for ; Thu, 18 May 2006 10:40:09 +0000 (UTC) (envelope-from kyrreny@broadpark.no) Received: from osl1smout1.broadpark.no (osl1smout1.broadpark.no [80.202.4.58]) by mx1.FreeBSD.org (Postfix) with ESMTP id CC22C43D46 for ; Thu, 18 May 2006 10:40:08 +0000 (GMT) (envelope-from kyrreny@broadpark.no) Received: from osl1sminn1.broadpark.no ([80.202.4.59]) by osl1smout1.broadpark.no (Sun Java System Messaging Server 6.1 HotFix 0.05 (built Oct 21 2004)) with ESMTP id <0IZG005QSIYVY330@osl1smout1.broadpark.no> for questions@freebsd.org; Thu, 18 May 2006 12:40:07 +0200 (CEST) Received: from urban.broadpark.no ([80.203.212.30]) by osl1sminn1.broadpark.no (Sun Java System Messaging Server 6.1 HotFix 0.05 (built Oct 21 2004)) with ESMTP id <0IZG00EPUIYVZ4D0@osl1sminn1.broadpark.no> for questions@freebsd.org; Thu, 18 May 2006 12:40:07 +0200 (CEST) Date: Thu, 18 May 2006 12:40:08 +0200 From: Kyrre Nygard To: questions@freebsd.org Message-id: <7.0.1.0.2.20060518123424.02289418@broadpark.no> MIME-version: 1.0 X-Mailer: QUALCOMM Windows Eudora Version 7.0.1.0 Content-type: text/plain; charset=us-ascii; format=flowed Content-transfer-encoding: 7BIT Cc: Subject: Shell script cannot run on FAT32 partition X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 May 2006 10:40:09 -0000 Hello! I have this nice renaming script here. It sanitizes badly named parts of files and folders. But when I run it on my FAT32, dual boot transition partition (hehe), it causes my computer (Pentium 4, 3,2 GHz) to freeze. I vaguely remember seeing some message before it freezes saying "Locking from myself" or something like that, this is not recorded into /var/log/messages. It is very annoying actually because to rename a bunch of files I first have to copy them to my UFS2 partition, run the script, and then copy them back to the FAT32 partition. Does this problem sound familiar to anyone? Thanks! Anyway here is the script. #!/usr/local/bin/bash # # Rename files and folders in MP3 releases. # $MERHABA: mp3_rename.sh,v 1.0 2007/11/11 15:09:05 kyrre Exp $ # if [ $1 ]; then mv="echo"; else mv="mv"; fi function do_folders () { for old in *; do if [ -f "$old" ]; then do_files "$old" elif [ -d "$old" ]; then new=`echo "$old" | tr "[:upper:]" "[:lower:]"` new=`echo "$new" | sed -e "s/ /_/g" \ -e "s/)//g" \ -e "s/-(/-/g" \ -e "s/_(/-/g" \ -e "s/(//g" \ -e "s/_-_/-/g" \ -e "s/---*/-/g" \ -e "s/___*/-/g" \ -e "s/\./_/g" \ -e "s/,/-/g" \ -e "s/'//g" \ -e "s/___*/_/g" \ -e "s/_-/-/g" \ -e "s/-_/-/g" \ -e "s/&/and/g" \ -e "s/\([-_]\)ft[_-]/\1feat_/g" \ -e "s/\([-_]\)featuring[_-]/\1feat_/g" \ -e "s/[][]//g"` if [ "$old" != "$new" ]; then $mv "$old" "$new"; fi echo "Renaming $old" cd "$new"; do_folders "$new"; cd .. else echo "Directory invalid."; fi done } function do_files () { old=$1 new=`echo "$old" | tr "[:upper:]" "[:lower:]"` if [[ "$old" == *.* ]]; then extension=${new##*.} new=${new%.*} new=`echo "$new" | sed -e "s/ /_/g" \ -e "s/)//g" \ -e "s/-(/-/g" \ -e "s/_(/-/g" \ -e "s/(//g" \ -e "s/_-_/-/g" \ -e "s/---*/-/g" \ -e "s/___*/-/g" \ -e "s/\./_/g" \ -e "s/,/-/g" \ -e "s/'//g" \ -e "s/___*/_/g" \ -e "s/_-/-/g" \ -e "s/-_/-/g" \ -e "s/\&/and/g" \ -e "s/\([-_]\)ft[_-]/\1feat_/g" \ -e "s/\([-_]\)featuring[_-]/\1feat_/g" \ -e "s/^\([0-9]\{2,3\}\)_/\1-/g" \ -e "s/[][]//g"` new=`echo "$new"."$extension"` $mv "$old" "$new"; fi } do_folders .