-   Linux - Software (
-   -   how to process utf8 text of filenames to cp/ln (

thelordmule 11-06-2010 10:42 PM

how to process utf8 text of filenames to cp/ln
Hi everyone,

I have a unicode utf8 file containing filenames. I wish to process them with very basic scripts but the unicode is an issue.

A script to create symlinks to all the filenames and put them in a dir


while read line
        echo "${line}"
        ln -sF "${line}" /other/references/
done < filelist.txt

filelist.txt looks like this:

/other/test1/myfile with spaces.txt
/other/test1/myfile with spaces (2).txt

Any special way to address the unicode filenames? The links do not come out right. I am using Mac OSX GNU bash 3.2.48.

thelordmule 11-07-2010 02:23 PM

unfortunately I could not find a bash based solution. It seems the unicode files are linked correctly, whereas the normal one are not. I believe it may have something to do with the newline character because the last line of the file was always linked only when there was no extra newline.

I gave up and made a python script instead

import os
import sys

logfile = open(sys.argv[1], "r").readlines()
for line in logfile:
        os.system("ln -sF \""+filename+"\" /other/references/")

works wonderfully except for files with single quotes in their names ' '

All times are GMT -5. The time now is 01:32 PM.