File: comment_3._comment

package info (click to toggle)
git-annex 5.20141125
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 37,828 kB
  • ctags: 583
  • sloc: haskell: 42,582; sh: 1,080; ansic: 498; makefile: 316; perl: 125
file content (39 lines) | stat: -rw-r--r-- 1,114 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
[[!comment format=mdwn
 username="mhameed"
 ip="82.32.202.53"
 subject="problems with spaces in filenames"
 date="Wed Sep  5 09:38:56 BST 2012"
 content="""

Spaces, and other special chars can make filename handeling ugly.
If you don't have a restriction on keeping the exact filenames, then 
it might be easiest just to get rid of the problematic chars.

    #!/bin/bash

    function process() {
        dir="$1"
        echo "processing $dir"
        pushd $dir >/dev/null 2>&1

        for fileOrDir in *; do
            nfileOrDir=`echo "$fileOrDir" | sed -e 's/\[//g' -e 's/\]//g' -e 's/ /_/g' -e "s/'//g" `
            if [ "$fileOrDir" != "$nfileOrDir" ]; then
                echo renaming $fileOrDir to $nfileOrDir
                git mv "$fileOrDir" "$nfileOrDir"
            else
                echo "skipping $fileOrDir, no need to rename."
            fi
        done

        find ./ -mindepth 1 -maxdepth 1 -type d | while read d; do
        process "$d"
        done
        popd >/dev/null 2>&1
    }

    process .

Maybe you can run something like this before checking for duplicates.

"""]]