File path conversions - Windows to Linux +GRAMPS
Tim H.
bizdev at pwnspeak.com
Thu Jul 8 06:20:41 UTC 2010
On 07/07/2010 08:27 PM, NoOp wrote:
> While I'm in the process of upgrading my brother's WinXP computer, I've
> installed Gramps 3.2.3-1 so that he can compare/use. He currently uses
> Rootsmagic, so I exported as a GED and imported into Gramps. All is well
> on the Windows machine; all records came across (8758 people, 2145
> unique surnames) and the graphics (many) are appearing fine.
>
> I've exported the whole thing (including media) to a .gpkg (654.3MB) so
> that I can use on my linux systems. All of the entries came across w/o
> issues, but the problem is the media path/graphic naming conventions
> that he used. An example:
>
> C:\My Documents\My Pictures\<surname> Geneology\<surname>,<firstname>
> <middlename_or_initial> Certificate of Birth.jpg
>
> Some are even worse, and longer with added subfolders for individuals,
> pound (#) signs, etc., but that's pretty much convention he's used. Made
> sense to him so that he could easily look at the files in WinExplorer&
> see exactly what the files pertain to. Unfortunately the spaces, commas,
> periods, # signs et all are creating issues. My system reads them
> properly, i.e.:
>
> /home/<username>/<somename>_xml.gpkg.media/My Documents/My
> Pictures/<surname> Geneology/<surname>,<firstname>
> <middleinitial>/<sirname>,<firstname> <middleinitial>. Certificate of
> Birth.jpg
>
> But I'd like to figure out a way to clean all those up to no spaces,
> periods, commas, etc.
>
> Any suggestions on how I can batch convert all of those to
> path/filenames? Or am I doomed to having to go through each one
> individually?
>
>
>
I use this script I found on the net sometime ago. Feel free to alter
the definition of NEWLINE to your liking:
## Code Below ######################################
#!/bin/bash
if [ -n "$1" ]
then
if [ -d "$1" ]
then
cd "$1"
else
echo invalid directory
exit
fi
fi
for i in *
do
OLDNAME="$i"
NEWNAME=`echo "$i" | tr ' ' '_' | tr A-Z a-z | tr ',' '_' | sed
s/_-_/-/g| sed s/__/_/g`
if [ "$NEWNAME" != "$OLDNAME" ]
then
TMPNAME="$i"_TMP
echo ""
mv -v -- "$OLDNAME" "$NEWNAME"
# mv -v -- "$TMPNAME" "$NEWNAME"
fi
if [ -d "$NEWNAME" ]
then
echo Recursing lowercase for directory "$NEWNAME"
$0 "$NEWNAME"
fi
done
### End Code #########################################
Tim H.
More information about the ubuntu-users
mailing list