Author Topic: Linux: to_lower.sh fix  (Read 2158 times)

Offline Fyorl

  • Planewalker
  • *****
  • Posts: 28
Linux: to_lower.sh fix
« on: May 22, 2006, 06:09:35 AM »
slight fix (added quotes around the variable names to accomodate filepaths with spaces etc.). The next version of WeiDU will not need this but in the meantime:

Code: [Select]
#!/bin/sh
#
# drake127 (2006-03-15)
#
# Rename all files in current directory and all its subdirectories to lower-case.
# If lower-case filename already exists, more recent one is preserved.
# Support for filepaths with spaces added by Fyorl (2006-05-22)

for file in `find -depth | sed -e 's/\ /\\\ /g'`
do
replace=`dirname $file`/`basename $file | tr [:upper:] [:lower:]`
if test $file != $replace -a $file != .
then
mv -u $file `dirname $file`/`basename $file | tr [:upper:] [:lower:]`
rm -f $file
fi
done

UPDATE:
*sigh* scratch that, it doesn't work but give me a minute

UPDATE #2
I'm fighting a losing battle here, the damn 'for file' keeps assigning a new $file every time it hits a space, even if that space is escaped >_<.

UPDATE #3
I give up. If you want, you can use this PHP script that I wrote which will do the trick just fine, but I doubt many people have PHP installed.

Code: [Select]
#!/usr/bin/php
<?php
# by Fyorl
# makes all files in the current directory (recursive) lowercase

$dir = `dirname $argv[0]`;
$dir trim($dir);
to_lower($dir);

function 
to_lower($dir)
{
$handle opendir($dir);

while(false !== ($file readdir($handle)))
{
$fp $dir '/' $file;

if($file == '.' || $file == '..')
{
continue;
}

$fpl strtolower($fp);
if($fp != $fpl)
{
exec("mv -u '$fp' '$fpl'; rm -f '$fp'");
}

if(is_dir($fpl))
{
to_lower($fpl);
}
}
}
?>
« Last Edit: May 22, 2006, 10:15:17 AM by Fyorl »

Offline FredSRichardson

  • Planewalker
  • *****
  • Posts: 188
  • Gender: Male
Re: Linux: to_lower.sh fix
« Reply #1 on: May 22, 2006, 08:59:01 AM »
I know this is a silly question, but is the Linux support for GemRB?  Utility scripts like this really make me wish that Windows had a Bash shell (I never got the hange of bat file scripting -- yick! :P).

Offline the bigg

  • The Avatar of Fighter / Thieves
  • Moderator
  • Planewalker
  • *****
  • Posts: 3804
  • Gender: Male
Re: Linux: to_lower.sh fix
« Reply #2 on: May 22, 2006, 09:20:04 AM »
I know this is a silly question, but is the Linux support for GemRB?  Utility scripts like this really make me wish that Windows had a Bash shell (I never got the hange of bat file scripting -- yick! :P).
BG2 runs fine (and case-insensitive) under Wine  :)
For bash-under-Winows : http://www.cygwin.com
Author or Co-Author: WeiDU (http://j.mp/bLtjOn) - Widescreen (http://j.mp/aKAiqG) - Generalized Biffing (http://j.mp/aVgw3U) - Refinements (http://j.mp/bLHoCc) - TB#Tweaks (http://j.mp/ba02Eg) - IWD2Tweaks (http://j.mp/98OFYY) - TB#Characters (http://j.mp/ak8J55) - Traify Tool (http://j.mp/g1Ry9A) - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics (http://j.mp/9UeIwB) - Nalia Mod (http://j.mp/dng9l0) - Nvidia Fix (http://j.mp/aRWjjg)
Code dumps: Detect custom secondary types (http://j.mp/hVzzXG) - Stutter Investigator (http://j.mp/gdtBn8)

If possible, send diffs, translations and other contributions using Git (http://j.mp/aBZFrq).

Offline Fyorl

  • Planewalker
  • *****
  • Posts: 28
Re: Linux: to_lower.sh fix
« Reply #3 on: May 22, 2006, 09:30:46 AM »
I know this is a silly question, but is the Linux support for GemRB?  Utility scripts like this really make me wish that Windows had a Bash shell (I never got the hange of bat file scripting -- yick! :P).

gemRB can be compiled under Windows as well. It's really great but it's not up to the actual Infinity Engine standard

Offline FredSRichardson

  • Planewalker
  • *****
  • Posts: 188
  • Gender: Male
Re: Linux: to_lower.sh fix
« Reply #4 on: May 22, 2006, 09:37:44 AM »
I know this is a silly question, but is the Linux support for GemRB?  Utility scripts like this really make me wish that Windows had a Bash shell (I never got the hange of bat file scripting -- yick! :P).
BG2 runs fine (and case-insensitive) under Wine  :)
For bash-under-Winows : http://www.cygwin.com
Yes, I only wish we could assume WeiDU users all had Cygwin/Bash installed.  :)

I've never tried Wine before, but I understand it's an emulater (sort of like VMWare) so it has to emulate the same Windows file-system symantics.  If you want to run Bash within the Wine emulator, do you have to install Cygwin? :D

Offline FredSRichardson

  • Planewalker
  • *****
  • Posts: 188
  • Gender: Male
Re: Linux: to_lower.sh fix
« Reply #5 on: May 22, 2006, 09:40:23 AM »
gemRB can be compiled under Windows as well. It's really great but it's not up to the actual Infinity Engine standard

I haven't tried out gemRB in a long time.  I think it's a great project, and I hope it will succeed in the long term :)

Offline the bigg

  • The Avatar of Fighter / Thieves
  • Moderator
  • Planewalker
  • *****
  • Posts: 3804
  • Gender: Male
Re: Linux: to_lower.sh fix
« Reply #6 on: May 22, 2006, 09:45:03 AM »
Yes, I only wish we could assume WeiDU users all had Cygwin/Bash installed.  :)
Darwinism shall prevail in the end.

Quote
I've never tried Wine before, but I understand it's an emulater (sort of like VMWare) so it has to emulate the same Windows file-system symantics.  If you want to run Bash within the Wine emulator, do you have to install Cygwin? :D
IIRC, it allows Windows executables to be run at the same level of ELF files, and implements the Winows DLLs (or even allows you to use M$-ones instead), rather than emulating a full OS. There are also case-insensitive Ext2/3 and FAT/NTFS drivers for Linux, if you look around (although it should be able to avoid the problem).

Also, Elf executables should be launchable by Wine (with some exceptions, EG Avenger reported that you can't run an ELF file in pausing mode), but I'm not sure about Bash (although they probably use the default Linux executable handler, and thus they should work natively).
Author or Co-Author: WeiDU (http://j.mp/bLtjOn) - Widescreen (http://j.mp/aKAiqG) - Generalized Biffing (http://j.mp/aVgw3U) - Refinements (http://j.mp/bLHoCc) - TB#Tweaks (http://j.mp/ba02Eg) - IWD2Tweaks (http://j.mp/98OFYY) - TB#Characters (http://j.mp/ak8J55) - Traify Tool (http://j.mp/g1Ry9A) - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics (http://j.mp/9UeIwB) - Nalia Mod (http://j.mp/dng9l0) - Nvidia Fix (http://j.mp/aRWjjg)
Code dumps: Detect custom secondary types (http://j.mp/hVzzXG) - Stutter Investigator (http://j.mp/gdtBn8)

If possible, send diffs, translations and other contributions using Git (http://j.mp/aBZFrq).

Offline FredSRichardson

  • Planewalker
  • *****
  • Posts: 188
  • Gender: Male
Re: Linux: to_lower.sh fix
« Reply #7 on: May 22, 2006, 10:00:02 AM »
I'll have to look into Wine a bit more, it always looked like a bear to install.  Linux has no problem with FAT file partitions (maybe even NTFS ones) which are always case-insensative.  I would think there'd be a problem with using native ext2/3, since the OS has to allow for case sensative files for any other process accessing the same partition.  I'm sure there's no trouble accessing the emulator in a bash script from outside, but having a native windows app access Linux from within the emulator would be a neat trick :)

Offline the bigg

  • The Avatar of Fighter / Thieves
  • Moderator
  • Planewalker
  • *****
  • Posts: 3804
  • Gender: Male
Re: Linux: to_lower.sh fix
« Reply #8 on: May 22, 2006, 10:05:57 AM »
from within the emulator
Wine = Wine Is Not (an) Emulator. It allows you to run Windows executables pretty much like you run Linux executables (= from an interpreter, not from a virtual machine), and implements good portions of the Windows API (allowing you to load both dlls or drivers from the ones in your Windows installation when they are missing).

The default FAT file system on Linux is case-sensitive, BTW  :o
Author or Co-Author: WeiDU (http://j.mp/bLtjOn) - Widescreen (http://j.mp/aKAiqG) - Generalized Biffing (http://j.mp/aVgw3U) - Refinements (http://j.mp/bLHoCc) - TB#Tweaks (http://j.mp/ba02Eg) - IWD2Tweaks (http://j.mp/98OFYY) - TB#Characters (http://j.mp/ak8J55) - Traify Tool (http://j.mp/g1Ry9A) - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics (http://j.mp/9UeIwB) - Nalia Mod (http://j.mp/dng9l0) - Nvidia Fix (http://j.mp/aRWjjg)
Code dumps: Detect custom secondary types (http://j.mp/hVzzXG) - Stutter Investigator (http://j.mp/gdtBn8)

If possible, send diffs, translations and other contributions using Git (http://j.mp/aBZFrq).

Offline FredSRichardson

  • Planewalker
  • *****
  • Posts: 188
  • Gender: Male
Re: Linux: to_lower.sh fix
« Reply #9 on: May 22, 2006, 01:07:35 PM »
The default FAT file system on Linux is case-sensitive, BTW  :o
Whoah, really?  It seems like this would break if you mounted a Linux FAT partition on Windows.

I'll have to read up on Wine, I think I misunderstood what it is and does.

Offline Fyorl

  • Planewalker
  • *****
  • Posts: 28
Re: Linux: to_lower.sh fix
« Reply #10 on: May 23, 2006, 06:38:44 AM »

Offline the bigg

  • The Avatar of Fighter / Thieves
  • Moderator
  • Planewalker
  • *****
  • Posts: 3804
  • Gender: Male
Re: Linux: to_lower.sh fix
« Reply #11 on: May 23, 2006, 06:41:36 AM »
The Linux executable format is called 'ELF': http://en.wikipedia.org/wiki/Executable_and_Linkable_Format
Author or Co-Author: WeiDU (http://j.mp/bLtjOn) - Widescreen (http://j.mp/aKAiqG) - Generalized Biffing (http://j.mp/aVgw3U) - Refinements (http://j.mp/bLHoCc) - TB#Tweaks (http://j.mp/ba02Eg) - IWD2Tweaks (http://j.mp/98OFYY) - TB#Characters (http://j.mp/ak8J55) - Traify Tool (http://j.mp/g1Ry9A) - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics (http://j.mp/9UeIwB) - Nalia Mod (http://j.mp/dng9l0) - Nvidia Fix (http://j.mp/aRWjjg)
Code dumps: Detect custom secondary types (http://j.mp/hVzzXG) - Stutter Investigator (http://j.mp/gdtBn8)

If possible, send diffs, translations and other contributions using Git (http://j.mp/aBZFrq).

Offline Fyorl

  • Planewalker
  • *****
  • Posts: 28
Re: Linux: to_lower.sh fix
« Reply #12 on: May 23, 2006, 06:59:12 AM »
ah right, I didn't even know that but then again I never had the inclination to find out...

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: